Scott Klement wrote:
That's interesting. I'm pretty sure CEETSTA does exactly the same thing
as if %ADDR(PARM)=*NULL....
So I guess I'm wondering what's going on here... How the heck does
CEETSTA solve the problem? It does the same thing!
That's my understanding too. CEETSTA is advertised to work with omitted
parameters, not unpassed parameters. And if the parameter is passed but
omitted, %addr works fine.
I just tested this using C as the caller. When I call the program, here
is what the C module passes, and the three values that RPG procedure
gets from calling CEETSTA for parameters 1, 2, 3.
Parameters from C RPG output
--------------------------- ----------
(null,null,null) 0,0,0
( ) 0,0,0
("abcde") 1,0,0
( ) 1,0,0 <---- bad
("abcde", "12345") 1,1,0
("abcde", "12345", "ABCDE") 1,1,1
("abcde") 1,1,1 <---- bad
Here's my code. Compile with CRTCMOD, CRTRPGMOD, CRTPGM, taking the
defaults.
main()
{
char *nullPointer = 0;
myProc(nullPointer, nullPointer, nullPointer);
myProc();
myProc("abcde");
myProc();
myProc("abcde", "12345");
myProc("abcde", "12345", "ABCDE");
myProc("abcde");
}
H NOMAIN
D CEETSTA PR EXTPROC( 'CEETSTA' )
D present 10I 0
D parmNum 10I 0 CONST
D fb 12A OPTIONS(*OMIT)
D myProc PR extproc('myProc')
D parm1 1A
D parm2 1A
D parm3 1A
P myProc b export
D myProc PI
D parm1 1A
D parm2 1A
D parm3 1A
D present1 s 10i 0
D present2 s 10i 0
D present3 s 10i 0
/free
CEETSTA (present1 : 1 : *omit);
CEETSTA (present2 : 2 : *omit);
CEETSTA (present3 : 3 : *omit);
dsply (%char(present1) + ',' + %char(present2) + ','
+ %char(present3));
/end-free
P myProc e
As an Amazon Associate we earn from qualifying purchases.