|
Nope!
It doesn't work like C. :(
A null-value or null ptr isn't the same as no parameter to the RPG
language. :(
You'd actually have to call Proc2 with no parms if no parms were passed,
something like this:
if %parms >=1;
Proc2( InArg1 );
else;
Proc2();
endif;
Otherwise Proc2() will always think it has a parm passed, that is %Parms
always returns 1.
As to OPTIONS(*OMIT)... What a nightmare!!!
callP Proc1(*OMIT);
... Then later, in Proc1...
If %Parms >=1;
if %addr(InArg1) = *NULL;
Proc2();
return;
endif;
endif;
Proc2(InArg1);
Oh, and don't forget all those semi-colons in free-format;;;;;;;;;;;
-Cozzi
-----Original Message-----
From: rpg400-l-bounces@midrange.com
[mailto:rpg400-l-bounces@midrange.com] On Behalf Of Steve Richter
Sent: Wednesday, January 08, 2003 11:03 AM
To: Chat. Rpg400-L
Subject: passing along *NoPass arguments
Proc1 receives an arg that is *NoPass:
pProc1 b
dProc1 pi
d InArg1 n options(*NoPass)
/free
Proc2( InArg1 ) ;
/end-free
p e
and passes it along to Proc2 which also defines the arg as *NoPass:
pProc2 b
dProc2 pi
d InArg1 n options(*NoPass)
/free
if %parms >= 1 ;
dsply 'Arg1 is passed' ;
endif ;
/end-free
p e
In practice, Proc2 always thinks it was passed an argument. Even when
Proc1 is called without an arg value.
Shouldnt passing a not passed *NoPass argument either signal an
exception or pass along the *NoPass indicator?
I was hoping that options(*NoPass:*Omit) was the answer. That a missing
arg value would be passed as *Omit and passed downstream as *Omit also.
But it does not work that way. Unless Proc1 is called as "Proc1( *Omit
) ;", Proc2 will think it was passed something.
Steve Richter
_______________________________________________
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/mailman/listinfo.cgi/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-2025 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.