CL Programming

Defining Lists within Lists

A list within a list can be:

The following is an example of lists within a list.

STMT((START RESPND) (ADDDSP CONFRM))

The outside set of parentheses enclose the list that can be specified for the parameter (the outer list) while each set of inner parentheses encloses a list within a list (an inner list).

In the following example, a mixed list is defined within a simple list. A mixed list is specified, and the MAX value on the PARM statement is greater than 1; therefore, the mixed list can be specified up to the number of times specified on the MAX parameter.

        PARM KWD(PARM1) TYPE(LIST1) MAX(5)
LIST1:  ELEM TYPE(*CHAR) LEN(10)
        ELEM TYPE(*DEC) LEN(3 0)

In this example, the two elements can be specified up to five times. When a value is entered for this parameter, it could appear as follows:

PARM1((VAL1 1.0) (VAR2 2.0) (VAR3 3.0))

In the following example, a simple list is specified as a value in a mixed list. In this example, the MAX value on the ELEM statement is greater than 1; therefore, the element can be repeated up to the number of times specified on the MAX parameter.

        PARM KWD(PARM2) TYPE(LIST2)
LIST2:  ELEM TYPE(*CHAR) LEN(10) MAX(5)
        ELEM TYPE(*DEC) LEN(3 0)

In this example, the first element can be specified up to five times, but the second element can be specified only once. When a value is entered for this parameter, it could appear as follows.

PARM2((NAME1 NAME2 NAME3) 123.0)

When lists within lists are passed to the command processing program, the format varies depending on whether you are using CL or HLL, or REXX. The following section describes how elements are passed using CL and HLL. For an explanation of the differences when using REXX, see Using REXX for Lists within Lists.

Using CL or HLL for Lists within Lists

When a command is run using CL or HLL, a list within a list is passed to the command processing program in the following format:
When a command is run using CL or HLL, a list within a list is passed to the command processing program in the this format.

The number of lists is passed as a binary value of length 2. Following the number of lists, the displacement to the lists is passed (not the values that were entered in the lists). Each displacement is passed as a binary value of length 2 or length 4 depending on the value of the LISTDSPL parameter.

The following example shows a definition for a parameter KWD2 (which is a mixed list within a simple list) how the parameter can be specified by the display station user, and what is passed. The parameter definition is:

       PARM    KWD(KWD2)    TYPE(LIST) MAX(20) MIN(0) +
               DFT(*NONE)  SNGVAL(*NONE)  LISTDSPL(*INT2)
LIST:  ELEM    TYPE(*CHAR)  LEN(10) MIN(1)       /*From value*/
       ELEM    TYPE(*CHAR)  LEN(5) MIN(0)        /*To value*/

The display station user enters the KWD2 parameter as:

KWD2((A B))

The following is passed to the command processing program:
Example of what is passed to the command processing program when the display station user enters the KWD2 parameter as KWD2((A B)).

If the display station user enters the following instead:

KWD2((A B) (C D))

the following is passed to the command processing program:
Example of what is passed to the command processing program when the display station user enters KWD2((A B) (C D)).

Lists within a list are passed to the command processing program in the order n (the last one entered by the display station user) to 1 (the first one entered by the display station user). The displacements, however, are passed from 1 to n.

The following is a more complex example of lists within lists. The parameter definition is:

        PARM    KWD(PARM1)  TYPE(LIST3)  MAX(25)
LIST3:  ELEM    TYPE(LIST4)
        ELEM    TYPE(*CHAR)  LEN(3)
        ELEM    TYPE(*NAME)  LEN(2)  MAX(5)
LIST4:  ELEM    TYPE(*DEC) LEN(7 2)
        ELEM    TYPE(*TIME)
 

If the display station user enters the PARM1 parameter as:

PARM1(((11.1  120900)  A  (A1  A2))  ((-22.2  131500)  B  (B1  B2)))

the following is passed to the command processing program:



RV2W506

Using REXX for Lists within Lists

When a command is run using REXX, a list within a list is passed to the command processing program just as the values are entered for the parameters. Trailing blanks are not passed.

The following example shows a definition for a parameter KWD2, which is a mixed list within a simple list, how the parameter can be specified by the display station user, and what is passed. The parameter definition is:

       PARM    KWD(KWD2)    TYPE(LIST) MAX(20) MIN(0) +
               DFT(*NONE)  SNGVAL(*NONE)
LIST:  ELEM    TYPE(*CHAR)  LEN(10) MIN(1)       /*From value*/
       ELEM    TYPE(*CHAR)  LEN(5) MIN(0)        /*To value*/

The display station user enters the KWD2 parameter as:

KWD2((A B))

The following is passed to the command processing program:

KWD2(A B)

If the display station user enters the following instead:

KWD2((A B) (C D))

The following is passed to the command processing program:

KWD2((A B) (C D))

The following is a more complex example of lists within lists. The parameter definition is:

        PARM    KWD(PARM1)  TYPE(LIST3)  MAX(25)
LIST3:  ELEM    TYPE(LIST4)
        ELEM    TYPE(*CHAR)  LEN(3)
        ELEM    TYPE(*NAME)  LEN(2)  MAX(5)
LIST4:  ELEM    TYPE(*DEC) LEN(7 2)
        ELEM    TYPE(*TIME)
 

The display station user enters the PARM1 parameter as:

PARM1(((11.1  12D900)  A  (A1  A2))  ((-22.2  131500)  B  (B1  B2)))

The following is passed to the command processing program:

PARM1(((11.1  12D900)  A  (A1  A2))  ((-22.2  131500)  B  (B1  B2)))


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