<snip>
When calling an ILE program or procedure, the operating system does not
check the number of parameters that are passed on the call. In addition,
the space where the operating system stores the parameters is not
reinitialized between program or procedure calls. Calling a program or
procedure that expects n parameters with n-1 parameters makes the system
use whatever is in the parameter space to access the nth parameter. The
results of this action are very unpredictable. This also applies to
programs or procedures written in other ILE languages that call CL
programs or procedures or are called by CL programs or procedures.
</snip>
This seems to tie in well with Scott's example where he called it three
times.
First time with one parameter and the null on the second parameter was
valid.
He called it with two parameters.
He called it again with only one parameter and the second parameter was
not initialized back to null.
"If" you are using the *OMIT as part of a bound call then checking for
null is a recommended technique.
<snip>
You can also specify the special value *OMIT for any parameter that you
want to omit from the parameter list on the Call Bound Procedure (CALLPRC)
command. If you specify *OMIT for a parameter, the calling program or
procedure passes a null pointer. The program or procedure that is called
has to be prepared to handle a null pointer if it refers to a parameter
that is omitted. In control language (CL), you can check for a null
pointer by monitoring for MCH3601 on the first reference to the omissible
parameter. The program or procedure must take appropriate action if it
receives a MCH3601.
</snip>
A technique is given where "also uses the CEEDOD API to determine the
actual length that is passed for the second parameter.". Now I am unsure
if that is only safe because the logic of that particular program says if
the first parameter is such-and-such then there is a second parameter.
All this is at:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rbam6/passp.htm
Rob Berendt
As an Amazon Associate we earn from qualifying purchases.