CL Programming

Writing a CL or HLL Command Processing Program

Figure 9-3 shows the relationship between the Create Command (CRTCMD) command, the command definition statements, and the command processing program.

Figure 9-3. Command Relationships for CL and HLL

Command Relationships for CL and HLL

If the command processing program is a program written in CL, the variables that receive the parameter values must be declared to correspond to the type and length specified for each PARM statement. The following shows this correspondence. (Note the declare for the parameter ORDER in Figure 9-3.)

PARM Statement Type PARM Statement Length Declared Variable Type Declared Variable Length
*DEC x y1 *DEC x y1
*LGL 1 *LGL 1
*CHAR n *CHAR <=n2
*NAME n *CHAR <=n2
*CNAME n *CHAR <=n2
*SNAME n *CHAR <=n2
*GENERIC n *CHAR <=n2
*CMDSTR n *CHAR <=n2
*DATE 7 *CHAR 7
*TIME 6 *CHAR 6
*INT2 n *CHAR 2
*INT4 n *CHAR 4
*UINT2 n *CHAR 2
*UINT4 n *CHAR 4

1
x equals the length and y is the number of decimal positions.

2
For character variables, if the length of the value passed is greater than the length declared, the value is truncated to the length declared. If RTNVAL(*YES) is specified, the length declared must equal the length defined on the PARM statement.

A program written in CL used as a command processing program can process binary values (such as *INT2 or *INT4). The program should receive these values as character fields. The binary built-in function (%BINARY) can be used to convert them to decimal values.

The difference between *INT2 or *INT4 and *UINT2 or *UINT4 is that the *INT 2 and *INT4 types are signed integers and the *UINT2 and *UINT4 types are unsigned integers. The default value for both *UINT2 and *UINT4 is 0. The *UINT2 and *UINT4 types have the same restrictions as the *INT and *INT4 types.

Note:
The %BINARY built-in function is for use with signed integers. There is no corresponding function for unsigned integers.

For examples of command processing programs, see Examples of Defining and Creating Commands.


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