|
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 mailing list archive is Copyright 1997-2026 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.