%PARMNUM (Return Parameter Number)
%PARMNUM returns the number of the parameter in the parameter list. The operand for %PARMNUM is the name of a parameter defined as part of a procedure interface.
Note:
- A parameter defined using a *ENTRY PLIST cannot be specified as the operand for %PARMNUM.
- The parameter must be specified the same way it appears in the procedure interface parameter list. If the parameter is an array, an index cannot be specified. If the parameter is a data structure, a subfield cannot be specified. If the parameter is a file, a record format cannot be specified.
- If the RTNPARM keyword is coded for a procedure, the return value is handled as an additional first parameter. The other parameters have a number one higher than the apparent number. For example, if a procedure defined with RTNPARM has two parameters P1 and P2, %PARMNUM(P1) will return 2 and %PARMNUM(P2) will return 3.
For more information, see Built-in Functions.
D myProc pi 10A RTNPARM OPDESC
D companyName 25A OPTIONS(*VARSIZE)
D errorCode 1A OPTIONS(*OMIT)
D cityName 25A OPTIONS(*NOPASS)
/free
// test the length of companyName
callp CEEDOD(%parmnum(companyName) : more parameters ...
: parmlen : *omit);
if parmlen < 25;
// the full parameter was not passed
endif;
// test the presence of the omissible errorCode parameter
callp CEETSTA(isPresent : %parmnum(errorCode) : *omit);
if isPresent = 1;
// errorCode was not omitted
endif;
// test the presence of the optional city parameter
if %parms >= %parmnum(cityName);
// cityName was passed
endif;