|
Hi Tim, You are assuming that a prototype is like a PLIST - it isn't. Look at it this way:- - A PI definition is the equivelent of a *ENTRY PLIST. - The compiler needs to validate any PI definition and any CALLP style call (either using a CALLP operation or a BIF style call, as in your example). - To do this validation, the compiler needs a template to validate against - that is what the prototype is for. To get the idea of this - try removing the field names in the prototype and recompiling - it will compile just fine, because the prototype is not defining anything that is used by the program - only by the compiler. HTH Paul Tuohy ----- Original Message ----- From: "Tim Kredlo" <TKredlo@xxxxxxxxxxxxxxxx> To: <RPG400-L@xxxxxxxxxxxx> Sent: Wednesday, October 15, 2003 1:10 AM Subject: Not grasping concept > Please help! > > I am having a VERY difficult time grasping the concepts behind > prototypes/return values/procedure interfaces. > Here is what I understand the recommended process to be: > > Define a prototype for the subprocedure (TESTSP). and store it in the > source PROTSP. > > It will return a numeric field 15 characters long with 3 decimals > and it requires 3 numeric input parameters. > D TestSP PR 15S 3 > D Unit 2S 0 > D Qnty 8S 0 > D Long 3S 0 > > So far, so good. > > Now I am going to write the subprocedure itself. > H NOMAIN > // Include the prototype > /Copy PRODLIB/QRPGSRC/PROTSP > Still OK. BUT then: > // Define the procedure interface > D TestSP PI > D Unit 1A > D Qnty 8S 0 > D Long 3S 0 > Why is this necessary? > Didn't the included prototype already declare these fields? > Wasn't that the purpose of the prototype? > > // Declare the field to be returned: > D Footage 15S 3 > Why is this necessary? > Didn't the prototype already declare the return value > type/length/decimals? > > /Free > //Calculate the return value > Footage = Unit * Qnty * Long; > // Return the calculated value > Return Footage; > /End-Free > > I must be missing some very basic concepts, because I would have thought > that the following was ALL that SHOULD be necessary for subprocedure > TestSP: > > H NOMAIN > // Include the prototype > /Copy PRODLIB/QRPGSRC/PROTSP > // Calculate and return value > /Free > TestSP = Unit * Qnty * Long; > /End-Free > > No PI defined - already did that in the prototype. > No "Return" variable defined - use the subprocedure name. Type, etc. > defined on prototype PR line. > No Return statement required - stated in prototype that the subprocedure > returns a 15S 3 variable. > > Please - what am I missing? > Where can I go to get an explanation as to WHY I need to add > what I consider (obviously incorrectly) unnecessary coding? > > OR: Am I coding things here that ARE unnecessary? > > Thanks in advance for any help. > > Frustrated, uninformed, and confused (but only in my mind), > > Tim Kredlo > > > > > > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/rpg400-l > or email: RPG400-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.