Command reference / CL
SELECT
Select
Begins a control structure for conditional processing of command groups. The group ends with ENDSELECT and must contain one or more WHEN commands, with an optional OTHERWISE. The first WHEN whose condition is true has its THEN command run, then control passes to ENDSELECT. Only one WHEN or the OTHERWISE is processed per SELECT group. If no WHEN condition is true, OTHERWISE runs when specified.
Allowed environments: *BPGM, *IPGM.
Use within a CL program.
Positional parameters: 0.
Restrictions
- Valid only within a CL program or ILE CL procedure.
- Up to 25 levels of nested SELECT commands are allowed.
Parameters
No parameters.
Examples
SELECT / WHEN COND(&INT *LT 0) THEN(DO) / ...group of CL commands... / ENDDO / WHEN COND(&INT *EQ 0) / WHEN COND(&INT *GT 0) THEN(CHGVAR &INT (&INT - 1)) / ENDSELECT
Conditions on the WHEN commands are evaluated in order. When a COND is true, its THEN command is processed, and control then passes to the command after ENDSELECT.
Generated from os/cl/catalog/SELECT.json and os/cl/help/SELECT.json.