|
Bob, I am not sure from David's example, but it looks like he has eliminated that the possibility of resolving this in the called procedure. For example, if you have say four optional parms with no interdependencies, the caller has to code 16 calls. At least that is what works for me. I have passed parms strait through and had it work, but not consistently. Sometimes a better solution for strings is to use variable length parameters that are always passed. That way you can key off of the length. David Morris >>> cozzi@rpgiv.com 11/28/01 09:07AM >>> Don't you think coding the "IF %PARMS > 3" style is easier than requiring, say for example, the caller to code EVAL X = Myproc('abcd' : *OMIT : *OMIT : *OMIT) I'd recommend handling it in the called procedure with %PARMS. Of course you could do both *NOPASS and *OMIT that way they can skip, say parm 2 and specify parms 3 and 4. Bob Cozzi cozzi@rpgiv.com Visit the new on-line iSeries Forums at: http://www.rpgiv.com/forum > -----Original Message----- > From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On > Behalf Of David Gibbs > Sent: Wednesday, November 28, 2001 9:57 AM > To: 'RPG400 Mailing List' > Subject: Using *OMIT & *NOPASS > > Folks: > > I've got a bit of a quandary... We've been writing a number procedures that > have a variable number of parameters. > > These procedures, in turn, call other procedures that also have a variable > number of parameters. The two procedures have very similar (if not > identical) parameter lists ... but the called parameter might call a > different procedure based on a control file. > > I made the erroneous conclusion that if a parameter was not passed, it's > address would be set to *NULL (similar to passing *OMIT). > > So, the question is ... what is the best way to handle possibility unpassed > parameters without having to code a complex structure of "if %parms > 2, > call w/ 3 params, if %parms > 3, call w/ 4 params", etc? > > Here's a quick pseudocode of what we are doing... > > Program Z > > callp x(a,b) > > end pgm z > > Proc X (a, b *nopass, c *nopass) > > if control file say one thing > return Y (a,b,c) > else > return W (a,b,c) > endif > > end proc X > > Proc Y (a, b *nopass, c *nopass) > > do stuff > > end proc Y > > Proc W (a, b *nopass, c *nopass) > > do other stuff > > end proc Y > > > david > > -- > David Gibbs > Sr. Software Engineer > MKS, Inc. > 2500 S. Highland Ave, Suite 200 > Lombard, IL 60148 > (630) 495-2108 x5004 > > Need a laugh (we all do these days): visit http://www.userfriendly.org
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.