|
Please help a sub-procedure novice! I currently have a program (call it 'MidPgm') that is called by many other programs (call them 'TopPgm's). MidPgm then executes subroutines whose names had been specified and passed as parameters by 'TopPgm'. These names are moved into an array (Subr) which is Looped through and the subroutines are executed. All these subroutines require the same type of input and return data of the same format (a record, number, and a code). This is accomplished by using 'when' statements. For Idx = 1 to 5; Select; When Subr(Idx) = 'GetMax'; Exsr GetMax; When Subr(Idx) = 'GetMin'; Exsr GetMin; etc.... EndSl; EndFor; Since these subroutines are also included in other 'mid' type programs, I am hoping to replace them with external subprocedures (call them 'BotPgm's). I was hoping for a way to reduce coding lines and make this procedure more 'reusable', if not generic, with something along the following lines. TopPgm would pass subprocedure names instead of subroutine names. MidPgm and BotPgms would include a '/copy' member containing a 'generic' prototype for the BotPgms with a 'variable' name, since all the subprocedures would have identical input and return parameters. ********* PROBLEM AREA ********** (Can't use ExtPgm with a procedure that returns a parameter) (can't use 'character variable' as parameter for ExtProc) (can't use 'character variable' as parameter for %PAddr) (can't have this PR refer to more than 1 ExtProc) D CalPgm PR LikeDs(OutPrmsDs) ExtProc(VarName) D InPrms LikeDs(InPrmsDs) (note: OutPrmsDs and InPrmsDs are also declared in the /copy member) The 'For' loop would be changed to: For Idx = 1 to 5; If Subr(Idx) <> *Blank; ********* PROBLEM AREA ********** VarName = Subr(Idx); OutPrms = VarName(InPrms); EndIf; Since I can resolve this in my head ( the program name (in VarNam) is known, It's tied it to the prototype 'CalPgm' for parameter resolution) I would think there would be a way to code this, but I AM STUCK. Any help would be appreciated. Tim Kredlo (still confused, but not as much as I was a week ago)
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.