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



Here is one possibility, but I don't know whether it would work as I haven't
tried it:

In program X set-up two based variables: b2,c2 (based on bptr, cptr)
Then load the basing pointers with the address of the actual parameter if it
has been passed.
Thus you pass along a null pointer if it has not been passed.

You still have to use %parms, but only once in the program.

Here's the code (I've marked the lines I've changed:

Proc X (a, b *nopass, c *nopass)
D B2      S         BASED(BPTR) <
D C2      S         BASED(CPTR) <
C         IF   %Parms>=2                <
C         Eval BPTR = %ADDR(B)  <
C         ENDIF                         <
C         IF   %Parms>=3                <
C         Eval CPTR = %ADDR(C)  <
C         ENDIF                         <
if control file say one thing
        return Y (a,b2,c2)              <
else
        return W (a,b2,c2)              <
endif
end proc X


Program Z
callp x(a,b)
end pgm z


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

-----Original Message-----
From: David Gibbs [mailto:dgibbs@mks.com]
Sent: 28 November 2001 15:57
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

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


================================================================
The integrity of this message cannot be guaranteed on the Internet.
Natexis Metals Limited cannot therefore be considered responsible
for the contents. Any unauthorised use or dissemination is prohibited.
If you are not the intended recipient of this message please delete it
and notify the sender.

*** PLEASE NOTE AS FROM 28TH JUNE 2001, OUR EMAIL ***
*** ADDRESS FORMAT WILL BE :
                            firstname.surname@natexismetals.com



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.