Variables that replace reserved or numeric parameter values

Character variables can be used for some commands to represent a value on the command parameter.

Some CL commands allow both numeric or predefined (reserved) values on certain parameters. Where this is true, you can also use character variables to represent the value on the command parameter.

Each parameter on a command can accept only certain types of values. The parameter can allow an integer, a character string, a reserved value, a variable of a specified type, or some mixture of these, as values. Some types of values are required for parameters. If the parameter allows numeric values (if the value is defined in the command as *INT2, *INT4, *UINT2, *UINT4, or *DEC) and also allows reserved values (a character string preceded by an asterisk), you can use a variable as the value for the parameter. The variable must be declared as TYPE(*CHAR) if you intend to use a reserved value.

For example, the Change Output Queue (CHGOUTQ) command has a Job separator (JOBSEP) parameter that can have a value of either a number (0 through 9) or the predefined default, *SAME. Because both the number and the predefined value are acceptable, you can also write a CL source program that substitutes a character variable for the JOBSEP value.


      PGM
      DCL &NRESP *CHAR LEN(6)
      DCL &SEP *CHAR LEN(4)
      DCL &FILNAM *CHAR LEN(10)
      DCL &FILLIB *CHAR LEN(10)
      DCLF.....
      .
      .
      .
LOOP: SNDRCVF.....
      IF (&SEP *EQ IGNR) GOTO END
      ELSE IF (&SEP *EQ NONE) CHGVAR &NRESP '0'
      ELSE IF (&SEP *EQ NORM) CHGVAR &NRESP '1'
      ELSE IF (&SEP *EQ SAME) CHGVAR &NRESP '*SAME'
      CHGOUTQ OUTQ(&FILLIB/&FILNAM) JOBSEP(&NRESP)
      GOTO LOOP
END:  RETURN
      ENDPGM

In the preceding example, the display station user enters information on a display describing the number of job separators required for a specified output queue. The variable &NRESP is a character variable manipulating numeric and predefined values (note the use of single quotation marks). The JOBSEP parameter on the Change Output Queue (CHGOUTQ) command will recognize these values as if they had been entered as numeric or predefined values. The DDS for the display file used in this program should use the VALUES keyword to restrict the user responses to IGNR, NONE, NORM, or SAME.

If the parameter allows a numeric type of value (*INT2, *INT4, *UINT2, *UINT4, or *DEC) and you do not intend to enter any reserved values (such as *SAME), then you can use a decimal or integer variable in that parameter.

Another alternative for this function is to use the prompter within a CL source program.