%PASSED (Return Parameter-Passed Condition)

%PASSED returns the *ON if the specified parameter was passed to the program or procedure and *OMIT was not passed as the parameter. The operand for %PASSED is the name of a parameter defined as part of the procedure interface for the current procedure.

Note:
  • Either *NOPASS or *OMIT must be specified for the OPTIONS of the procedure interface for the specified parameter.
  • A parameter defined using a *ENTRY PLIST cannot be specified as the operand for %PASSED.
  • A parameter specified in the procedure interface for the main procedure cannot be specified as the operand for %PASSED in different procedure.
  • 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.
Warning: If the passed parameter is based on a pointer and the pointer is null, the result of %PASSED depends on whether OPTIONS(*OMIT) is specified for the parameter.
  • If OPTIONS(*OMIT) is specified for the parameter, %PASSED returns *OFF. With OPTIONS(*OMIT), when the address of the parameter is null, it appears as though *OMIT was passed.
  • If OPTIONS(*OMIT) is not specified for the parameter, %PASSED returns *ON. When OPTIONS(*OMIT) is not specified, the address of the parameter is not checked for %PASSED.

For more information, see Built-in Functions.

Examples of %PASSED

  • The procedure interface for procedure A has three parameters.
    1. The parameter must be passed, but *OMIT can be passed for the parameter.
    2. The parameter is optional. *OMIT can be passed for the parameter.
    3. The parameter is optional. *OMIT cannot be passed for the parameter.
    
    dcl-proc a;
       dcl-pi *N;
         p1 char(10) options(*OMIT);           //  1 
         p2 char(10) options(*OMIT : *NOPASS); //  2 
         p3 char(10) options(*NOPASS);         //  3 
       end-pi;
    
    Several calls are made to the procedure.
    The call to procedure A Result of %PASSED(p1) Result of %PASSED(p2) Result of %PASSED(p3)
    a(fld1); *ON *OFF *OFF
    a(*OMIT); *OFF *OFF *OFF
    a(fld1 : fld2); *ON *ON *OFF
    a(fld1 : *OMIT); *ON *OFF *OFF
    a(fld1 : fld2 : fld3); *ON *ON *ON