× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Simon,

I agree with you.  I pretty much stick to the %addr.  I've got programs
which omit parameters in the middle, therefore %parms is worthless to me.
If I pass parm1 and parm3, but not parm2 then %parms = 2 but that is an
inaccurate method of determining which parameters were passed.

Rob Berendt
--
"They that can give up essential liberty to obtain a little temporary
safety deserve neither liberty nor safety."
Benjamin Franklin



                    "Simon Coulter"
                    <shc@flybynight.c       To:     rpg400-l@midrange.com
                    om.au>                  cc:
                    Sent by:                Fax to:
                    rpg400-l-admin@mi       Subject:     Re: Optional 
Parameters in Subproceedures
                    drange.com


                    02/18/2002 05:28
                    PM
                    Please respond to
                    rpg400-l







Hello Mike,

You wrote:
>Thanks, one more question. How can I tell if that parameter was passed or
>not?

That depends on how the parameter was coded on the prototype.

OPTIONS(*NOPASS) means the parameter is optional, i.e., it may not even be
there at all.

OPTIONS(*OMIT) means the parameter is omissable.  That means it is required
but you can specify *OMIT to cause a null pointer to be passed.

MEMORISE THIS *********
Optional and omissable are distinctly different things and not
interchangeable!
***********************

If the parameter is coded as OPTIONS(*NOPASS) then use %PARMS to check the
parameter count.

C                    IF        ( %PARMS >= 2 )
 *                   do stuff

If the parameter is coded as OPTIONS(*OMIT) then a null pointer is passed
and %PARMS will count it.  You can test the address using %ADDR and
comparing for *NULL. (You can also call CEETSTA to test for the omitted
argument but %ADDR is easier.)

C                    IF        ( %ADDR(parm1) <> *NULL )
 *                   do stuff

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

NOTE: In the above example I have prototyped the CEETSTA bound procedure so
I can use it on CALLP.  Without the prototype you have to code:

C                    CALLB          'CEETSTA'
C                    PARM                                argOmitted
C                    PARM           2                    argNbr
C                    PARM                                *OMIT

(or something like that -- I haven't used CALLB for years)

Regards,
Simon Coulter.

--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists
   http://www.flybynight.com.au/

   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------

_______________________________________________
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 thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.