CL Programming

Defining Parameters

You can define as many as 75 parameters for each command. To define a parameter, you must use the PARM statement.

On the PARM statement, you specify the following:

In addition, you must consider the following information when defining parameters. (The associated PARM statement parameter is given in parentheses.)

Naming the Keyword for the Parameter

The name of the keyword you choose for a parameter should be descriptive of the information being requested in the parameter value. For example, USER for user name, CMPVAL for compare value, and OETYPE for order entry type. The keyword can be as long as 10 alphanumeric characters, the first of which must be alphabetic.

Parameter Types

The basic parameter types are (parameter TYPE value given in parentheses):

The following parameter types are for IBM-supplied commands only.

Length of Parameter Value

You can also specify a length (LEN parameter) for parameter values of the following types. For parameter types of date or time, date is always 7 characters long and time is always 6 characters long. The following shows the maximum length for each parameter type and the default length for each parameter type for which you can specify a length.

Data Type Maximum Length Default Length
*DEC 24 (9 decimal positions) 15 (5 decimal positions)
*LGL 1 1
*CHAR 5000 32
*NAME 256 10
*SNAME 256 10
*CNAME 256 10
*GENERIC 256 10
*HEX 256 1
*X (256 24 9) (1 15 5)
*VARNAME 11 11
*CMDSTR 20K 256
*PNAME 5000 32

The maximum length that is shown here is the maximum allowed length for these parameter types when the command runs. However, the maximum length that is allowed for character constants in the command definition statements is 32 characters. This restriction applies to the CONSTANT, DFT, VALUES, REL, RANGE, SPCVAL, and SNGVAL parameters. There are specific lengths for input fields available when prompting for a CL command. The input field lengths are 1 through 12 characters and 17, 25, 32, 50, 80, 132, 256, and 512 characters. If a particular parameter has a length that is not allowed,the input field displays with the next larger field length. The prompter displays a 512-character input field for parameters that can be longer than 512 characters.

Default Values

If you are defining an optional parameter, you can define a value on the DFT parameter to be used if the user does not enter the parameter value on the command. This value is called a default value. The default value must meet all the value requirements for that parameter (such as type, length, and special values). If you do not specify a default value for an optional parameter, the following default values are used.

Data Type Default Value
*DEC 0
*INT2 0
*INT4 0
*UINT2 0
*UINT4 0
*LGL '0'
*CHAR Blanks
*NAME Blanks
*SNAME Blanks
*CNAME Blanks
*GENERIC Blanks
*DATE Zeros ('F0')
*TIME Zeros ('F0')
*ZEROELEM 0
*HEX Zeros ('00')
*NULL Null
*CMDSTR Blanks
*PNAME Blanks

Example of Defining a Parameter

The following example defines a parameter OETYPE for a command to call an order entry application.

PARM   KWD(OETYPE)  TYPE(*CHAR)  RSTD(*YES) +
       VALUES(DAILY WEEKLY MONTHLY)  MIN(1) +
       PROMPT('Type of order entry:')

The OETYPE parameter is required (MIN parameter is 1) and its value is restricted (RSTD parameter is *YES) to the values DAILY, WEEKLY, or MONTHLY. The PROMPT parameter contains the prompt text for the parameter. Since no LEN keyword is specified and TYPE(*CHAR) is defined, a length of 32 is the default.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]