Use CL or HLL for simple lists

This describes the format in which elements in a simple list are passed when a command is run using CL or a high-level language.

When the command is run using CL or HLL, the elements in a simple list are passed to the command processing program in the following format.


When the command is run using CL or HLL, the elements in a simple list are passed to the command processing program in this format.

The number of values passed is specified by a binary value that is two characters long. This number indicates how many values were actually entered (are being passed), not how many can be specified. The values are passed by the type of parameter just as a value of a single parameter is passed. For example, if two user names (BJONES and TBROWN) are specified for the USER parameter, the following is passed.


If two user names (BJONES and TBROWN) are specified for the USER parameter this is passed.

The user names are passed as 10-character values that are left-adjusted and padded with blanks.

When a simple list is passed, only the number of elements specified on the command are passed. The storage immediately following the last element passed is not part of the list and must not be referred to as part of the list. Therefore, when the command processing program (CPP) processes a simple list, it uses the number of elements passed to determine how many elements can be processed.

The example below shows a CL procedure using the binary built-in function to process a simple list.

Figure 1. Simple List Example
        PGM PARM (...&USER..)
        .
        .
        .
        /* Declare space for a simple list of up to five */
        /* 10-character values to be received            */
        DCL VAR(&USER) TYPE(*CHAR) LEN(52)
        .
        DCL VAR(&CT)    TYPE(*DEC)  LEN(3 0)
        DCL VAR(&USER1) TYPE(*CHAR) LEN(10)
        DCL VAR(&USER2) TYPE(*CHAR) LEN(10)
        DCL VAR(&USER3) TYPE(*CHAR) LEN(10)
        DCL VAR(&USER4) TYPE(*CHAR) LEN(10)
        DCL VAR(&USER5) TYPE(*CHAR) LEN(10)
        .
        .
        .
        CHGVAR  VAR(&CT) VALUE(%BINARY(&USER 1 2))
        .
        IF (&CT > 0) THEN(CHGVAR &USER1 %SST(&USER 3 10))
        IF (&CT > 1) THEN(CHGVAR &USER2 %SST(&USER 13 10))
        IF (&CT > 2) THEN(CHGVAR &USER3 %SST(&USER 23 10))
        IF (&CT > 3) THEN(CHGVAR &USER4 %SST(&USER 33 10))
        IF (&CT > 4) THEN(CHGVAR &USER5 %SST(&USER 43 10))
        IF (&CT > 5) THEN(DO)
        /*  If CT is greater than 5, the values passed     */
        /*  is greater than the program expects, and error */
        /*  logic should be performed                      */
        .
        .
        .
        ENDDO
        ELSE DO
        /* The correct number of values are passed */
        /* and the program can continue processing */
        .
        .
        .
        ENDDO
        ENDPGM

This same technique can be used to process other lists in a CL procedure or program.

For a simple list, a single value such as *ALL or *NONE can be entered on the command instead of the list. Single values are passed as an individual value. Similarly, if no values are specified for a parameter, the default value, if any is defined, is passed as the only value in the list. For example, if the default value *ALL is used for the USER parameter, the following is passed.


In this example the following is passed when the default value *ALL is used for the USER parameter.

*ALL is passed as a 10-character value that is left-adjusted and padded with blanks.

If no default value is defined for an optional simple list parameter, the following is passed:


In this example the following is passed if no default value is defined for an optional simple list parameter.
Related tasks
Define parameters