Parameters in keyword and positional form

You can specify parameters in CL using keyword form, positional form, or in a combination of the two.

Parameters in keyword form

A parameter in keyword form consists of a keyword followed immediately by a value (or a list of values separated by blank spaces) enclosed in parentheses. You cannot use blanks between the keyword and the left parenthesis preceding the parameter value. You can place blanks between the parentheses and the parameter value. For example, LIB(MYLIB) is a keyword parameter specifying that MYLIB is the name of the library that is used in some way, depending upon the command in which this LIB parameter is used.

When command parameters are all specified in keyword form, they can be placed in any order. For example, the following two commands are the same:

CRTLIB   LIB(MYLIB)  TYPE(*TEST)
CRTLIB   TYPE(*TEST)  LIB(MYLIB)

Parameters in positional form

A parameter in positional form does not have its keyword coded; it contains only the value (or values, if it is a list) whose function is determined by its position in the parameter set for that command. The parameter values are separated from each other and from the command name by one or more blank spaces. Because there is only one positional sequence in which parameters can be coded, the positional form of the previous CRTLIB (Create Library) command first example is:

CRTLIB   MYLIB  *TEST

If you do not want to enter a value for one of the parameters, the predefined value *N (null) can be entered in that parameter's position. The system recognizes *N as an omitted parameter, and either assigns a default value or leaves it null. In the previous CRTLIB command second example, if you coded *N instead of *TEST for the TYPE parameter, the default value *PROD is used when the command is run, and a production library named MYLIB is created. The description of the CRTLIB command contains the explanation for each parameter.

Note:
  • Parameters cannot be coded in positional form beyond the positional coding limit. If you attempt to code parameters in positional form beyond that point, the system returns an error message.
  • Using positional form in your CL program source may save time when writing the program, but will be more difficult for you or someone else to maintain. Commands written using keyword form are generally easier to understand and enhance.

Combining keyword and positional forms

A command may also have its parameters coded in a combination of keyword and positional forms. The following examples show three ways to code the Declare CL Variable (DCL) command.

Keyword form:

DCL   VAR(&QTY)  TYPE(*DEC)  LEN(5)  VALUE(0)

Positional form:

DCL   &QTY  *DEC  5  0

Positional and keyword forms together:

DCL   &QTY  *DEC  VALUE(0)

In the last example, because the optional LEN parameter was not coded, the VALUE parameter must be coded in keyword form.

Note: You cannot specify parameters positionally after a parameter specified in keyword form.
Related concepts
Command coding rules
Related reference
Command parameters