Variables in CL commands

A variable is a named changeable value that can be accessed or changed by referring to its name.

A CL source program consists of CL commands. Each command consists of a command name, parameter keyword names, and parameter values. Parameter values can be expressed as variables, constants, or expressions. Variables can be used as substitutes for most parameter values on CL commands. When a CL variable is specified as a parameter value and the command containing it is run, the value of the variable is used as the parameter value. Every time the command is run, a different value can be substituted for the variable. Variables and expressions can be used as parameter values only in CL procedures and programs.

Variables are not stored in libraries, and they are not objects. Their values are destroyed when the program or procedure that contains them is no longer active. The use of variables as values gives CL programming a special flexibility, because this allows high-level manipulation of objects whose content can be changed by specific applications. You might, for instance, write a CL source program to direct the processing of other programs or the operation of several workstations without specifying which programs or workstations are to be controlled. The system identifies these as variables in the CL program or procedure. You can define (specify) the value of the variables when you run the CL program or procedure.

In addition to the uses discussed in this topic, variables can be used to complete the following tasks:

Variables cannot be used to change a command name or keyword or to specify a procedure name for the CALLPRC command. Command parameters, however, can be changed during the processing of a CL procedure through the use of the prompting function.

It is also possible to assemble the keywords and parameters for a command and process it using the QCAPCMD API or QCMDEXC API.