|
I believe you're right, check both %parms and %addr. I wrote a simple program which returns: DSPLY 3 DSPLY ABC DSPLY 3 DSPLY DE DSPLY 1 DSPLY F Ø DSPLY 2 DSPLY GHØ H ActGrp(*caller) DftActGrp(*NO) D MySub PR like(r1) D x like(p1) const D x like(p2) Options(*nopass:*omit) const D x like(p3) options(*nopass) const D p1 s 1a D p2 s 1a D p3 s 1a D r1 s 3a /free r1=MySub('A':'B':'C'); dsply r1; r1=MySub('D':*omit:'E'); dsply r1; r1=MySub('F'); dsply r1; r1=MySub('G':'H'); dsply r1; *inlr=*on; return; /end-free P MySub B D MySub PI like(r1) D s1 like(p1) const D s2 like(p2) Options(*nopass:*omit) const D s3 like(p3) options(*nopass) const D retValue s like(MySub) D x s 10i 0 /free x=%parms; dsply x; retValue=s1; if %addr(s2)<>*null; retValue=%trim(retValue) + s2; endif; if %addr(s3)<>*null; retValue=%trim(retValue) + s3; endif; return retValue; /end-free P MySub E Rob Berendt -- "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." Benjamin Franklin "Bob Cozzi \(RPGIV\)" To: <rpg400-l@midrange.com> <cozzi@rpgiv.com> cc: Sent by: Fax to: rpg400-l-admin@mi Subject: RE: Optional Parameters in Subproceedures drange.com 02/19/2002 09:46 AM Please respond to rpg400-l Because if you do not specify a parameter value, you need to use %PARMS, if you specify *OMIT you need to use %ADDR()=*NULL. Myproc(parm1value : *OMIT : parm3Value) %Parms = 3 %addr( parm2Value ) = *NULL myproc(Parm1Value : Parm2Value ) %parms = 2 %addr(parm3Value) = ???? (runtime error?) Bob Cozzi cozzi@rpgiv.com Visit the on-line Midrange Developer forum at: http://www.rpgiv.com > -----Original Message----- > From: rpg400-l-admin@midrange.com [mailto:rpg400-l-admin@midrange.com] On > Behalf Of rob@dekko.com > Sent: Tuesday, February 19, 2002 8:32 AM > To: rpg400-l@midrange.com > Subject: RE: Optional Parameters in Subproceedures > > > If you are using the %addr, then why bother with the %parms? > > Rob Berendt > -- > "They that can give up essential liberty to obtain a little temporary > safety deserve neither liberty nor safety." > Benjamin Franklin > > > > Scott > Mildenberger To: "'rpg400-l@midrange.com'" > <rpg400-l@midrange.com> > <Smildenber@Washc cc: > orp.com> Fax to: > Sent by: Subject: RE: Optional > Parameters in Subproceedures > rpg400-l-admin@mi > drange.com > > > 02/19/2002 09:22 > AM > Please respond to > rpg400-l > > > > > > > Simon, > > In the OPTIONS(*NOPASS : *OMIT) case is there any reason you can't use the > %parms and %addr together? At least that is how I do it, just curious > because in the first part of your message you mentioned %addr was easier to > use but you didn't use it here. Want to make sure I'm not missing > something > by doing the following: > > C IF ( %PARMS >= 2 ) and (%addr(TheParm) <> > *NULL) > *** The parm can be used. > C ENDIF > > Scott Mildenberger > > > -----Original Message----- > > From: Simon Coulter [mailto:shc@flybynight.com.au] > > Sent: Monday, February 18, 2002 3:29 PM > > To: rpg400-l@midrange.com > > Subject: Re: Optional Parameters in Subproceedures > > > > If the parameter was coded as OPTIONS(*NOPASS : *OMIT) then > > you MUST use > > %PARMS followed by a call to CEETSTA to test for an omitted > > argument. The > > reason you must do it this way is that if the parameter was > > not specified > > at all CEETSTA will fail with a missing descriptor (or worse, > > pick up a > > descriptor on the stack from a previous function call). If *OMIT was > > specified then %PARMS will count it as a parameter. You must > > do both things > > to know whether you have a valid parameter or not. > > > > C IF ( %PARMS >= 2 ) > > C CALLP ceeTestArg( argOmitted : 2 : *OMIT ) > > C ENDIF > > > > C IF ( %PARMS >= 2 AND > > C argOmitted = $CEE_ARG_OMITTED_NO ) > > * do stuff > > > > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l > or email: RPG400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. > > > > > > _______________________________________________ > This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list > To post a message email: RPG400-L@midrange.com > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l > or email: RPG400-L-request@midrange.com > Before posting, please take a moment to review the archives > at http://archive.midrange.com/rpg400-l. _______________________________________________ This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list To post a message email: RPG400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/rpg400-l or email: RPG400-L-request@midrange.com 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.