|
Tim, I am having a VERY difficult time grasping the concepts behind prototypes/return values/procedure interfaces. Why is this necessary? The prototype being copied in after the procedure is another way to make sure that your parameters will line up. It would do no good to make sure that the procedure is called the same way (via /Copy member ), if the procedure was not interfaced the same way it is prototyped. By checking the /Copy member at compile time for the procedure, it helps insure that the parameter list you compiled with, and the parameter list you call with, are actually the same. 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? You do not actually need to declare a work variable here. Operations can be done on the return line and it does return the variable type you defined. Didn't the prototype already declare the return value type/length/decimals? Yes, it did. Again operation can be done on the return line. 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 You could code this Return (Unit * Qty * Long); In the world of C and C++ that I have been introduced to, it has always been necessary to define the interface and the implementation. Including the interface with the implementtion insures that in the /Copy member has not been changed, you can be sure that your procedure will pass its parameters correctly. Last, but not least, the P-Specs show the compiler where the procedure begins and ends. There can be several return statements in a proceudure and the P-Specs keep the procedures separated. HTH, Andy
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.