× 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.



"
Hello David,

There is no truly elegant way to handle this.  However you could have proc x
set appropriate defaults and always call Y and W with the full complement of
parameters.  For example

Proc X (a, b *nopass, c *nopass)

set my_B to default
set my_C to default

if (%parms >= 2)
        set my_B to b

if (%parms >= 3)
        set my_C to c

if control file say one thing
        return Y (a,my_B,my_C)
else
        return W (a,my_B,my_C)
endif

end proc X

You could also specify *OMIT rather than *NOPASS on the prototype thus
forcing your caller to pass *OMIT as a placeholder.  Since *OMIT does pass
something (a null pointer indicating nothing) you could simply pass that on
to Y and W.  This will certainly work when the called proc checks for parms
using the form: if (%addr(parm) <> *NULL)       but may not work if using
the CEE API to check for omitted parameters.  I haven't tried it so I don't
know for certain.  NOTE: forcing *OMIT is pretty ugly and will likely
irritate the caller.

You could also allow both *OMIT and *NOPASS  but that requires that you
first check %PARMS to determine if something was passed and then use the CEE
API to check for omitted parameters.  You cannot use the %addr(parm) method
because the compiler will not allow you take the address of a *NOPASS
parameter.

None of these techniques result in elegant code in the procedure that
implements the function but they do allow an elegance in the procedure
interface which may simplify your caller's code.

Regards,
Simon Coulter.

«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»
«» FlyByNight Software         AS/400 Technical Specialists       «»
«» Eclipse the competition - run your business on an IBM AS/400.  «»
«»                                                                «»
«» 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  / \   «»
«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»«»


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.