Rory,
I don't think your case statement will evaluate correctly... You should
start with "%parms > 9" and work your way down... As written, case will
always select the first clause, since this will always evaluate to true
whenever %parms > 2....
-Eric DeLong
-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Rory Hewitt
Sent: Tuesday, August 18, 2009 11:02 AM
To: RPG programming on the IBM i / System i
Subject: Re: CALL with optional parameters
Here's an example of what Jon's talking about:
D PgmToCallName S 21A
D PgmToCall PR Extpgm(PgmToCallName)
D Parm1 10A Const
D Parm1 10A Const
D Parm1 10A Const Options(*Nopass)
PgmToCallName = 'MYLIB/MYPGM';
PgmToCall( 'ABC' : 'DEF' : 'GHI' );
Back to the OP's original question though, the quick answer is that
aside
from the various techniques to prototype the call (which will only
minimize
the amount of code), you still have to explicitly do the check for the
extra
parm. Not a huge problem if you're talking about 1 extra parm, but if
there
are lots, then you get something like this:
select:
when %parms > 2;
PgmToCall( Parm1 : Parm2 : Parm3 );
when %parms > 3;
PgmToCall( Parm1 : Parm2 : Parm3 : Parm4 );
when %parms > 4;
PgmToCall( Parm1 : Parm2 : Parm3 : Parm4 : Parm5 );
....
when %parms > 9;
PgmToCall( Parm1 : Parm2 : Parm3 : Parm4 : Parm5 : Parm6:
Parm7: Parm8: Parm9: Parm10 );
endsl;
I've done this to 'wrapper' an internal (unexported) procedure.
Nothing you can do about it.
Rory
On Tue, Aug 18, 2009 at 8:14 AM, Jon Paris <jon.paris@xxxxxxxxxxxxxx>
wrote:
Yes you can - simply remove the quotes from the program name on the
EXTPGM and the compiler treats it as a variable just as with the old
CALL/PARM method.
Jon Paris
As an Amazon Associate we earn from qualifying purchases.