Defining a CL command list parameter
You can define a parameter to accept a list of values instead of just a single value.
You can define the following types of lists:
- A simple list, which allows one or more values of the same type to be specified for a parameter
- A mixed list, which allows a set of separately defined values to be specified for a parameter
- A list within a list, which allows a list to be specified more than once for a parameter or which allows a list to be specified for a value within a mixed list
The following sample command source illustrates the different types of lists:
CMD PROMPT('Example of lists command')
/* THE FOLLOWING PARAMETER IS A SIMPLE LIST. IT WILL ACCEPT UP TO */
/* 5 NAMES. */
PARM KWD(SIMPLST) TYPE(*NAME) LEN(10) DFT(*ALL) +
SPCVAL((*ALL)) MAX(5) PROMPT('Simple list +
of up to 5 names')
/* THE FOLLOWING PARAMETER IS A MIXED LIST OF 3 VALUES, EACH OF A */
/* DIFFERENT TYPE AND/OR LENGTH. EACH ELEMENT MAY NOT BE REPEATED. */
PARM KWD(MXDLST) TYPE(MLSPEC) PROMPT('This is a +
mixed list of 3 val')
MLSPEC: ELEM TYPE(*CHAR) LEN(4) PROMPT('Elem 1 of 3')
ELEM TYPE(*DEC) LEN(3 0) PROMPT('Second of three')
ELEM TYPE(*CHAR) LEN(10) PROMPT('Last of three +
elements')
/* THE FOLLOWING PARAMETER IS A LIST WITHIN A LIST. IT CONTAINS A */
/* LIST OF UP TO 2 ELEMENTS, WHICH MAY BE REPEATED UP TO 3 TIMES. */
PARM KWD(LWITHINL1) TYPE(LWLSPECA) MAX(3) +
PROMPT('Repeatable list of 2 elements')
LWLSPECA: ELEM TYPE(*CHAR) LEN(10) PROMPT('1st part of +
repeatable list')
ELEM TYPE(*DEC) LEN(5 0) PROMPT('2nd part of +
repeatable list')
/* THE FOLLOWING PARAMETER IS A LIST WITHIN A LIST. IT CONTAINS A */
/* LIST OF UP TO 2 ELEMENTS, THE FIRST OF WHICH MAY BE REPEATED */
/* UP TO 3 TIMES. */
PARM KWD(LWITHINL2) TYPE(LWLSPECB) MAX(1) +
PROMPT('Repeated simple within mixed')
LWLSPECB: ELEM TYPE(*CHAR) LEN(10) MAX(3) PROMPT('Simple +
list within a list')
ELEM TYPE(*DEC) LEN(5 0) PROMPT('Single parm +
within a list')
The following display shows the prompt for the preceding sample command.
Example of lists command (LSTEXAMPLE)
Type choices, press Enter.
Simple list of up to 5 names . . SIMPLST *ALL
+ for more values
This is a mixed list of 3 val MXDLST
Elem 1 of 3 . . . . . . . . .
Second of three . . . . . . .
Last of three elements . . . .
Repeatable list of 2 elements LWITHINL1
1st part of repeatable list .
2nd part of repeatable list .
+ for more values
Repeatable simple within mixed LWITHINL2
Simple list within a list . .
+ for more values
Single parm within a list . .
Bottom
F3=Exit F4=List F5=Refresh F12=Cancel F13=Prompter help
F24=More keys