Command reference / CL
ELSE
Else
Specifies a command, or a Do group, to run conditionally with an IF command. It is processed only when the IF expression is false. Each ELSE must have a preceding IF; with nested IFs, an ELSE matches the innermost IF not already matched with an ELSE. Commands that cannot be specified on ELSE include ENDDO, MONMSG, PGM, ENDPGM, DCL, DCLF, another ELSE, WHEN, OTHERWISE and ENDSELECT, and MONMSG cannot be the next command after ELSE.
Allowed environments: *BPGM, *IPGM.
Use within a CL program.
Positional parameters: 1.
Restrictions
- Valid only in a CL program or ILE CL procedure.
- Must have an associated IF command preceding it.
Parameters
CMD
Command
Names the command, or commands in a Do group, to run when the IF expression is false. If no command is given, no action is taken for a false condition.
Examples
IF (&A *GT &B) THEN(CHGVAR VAR(&A) VALUE(&B)) / ELSE (CHGVAR &B &A)
If &A is greater than &B, &A is set to &B. Otherwise the ELSE command runs, setting &B to the same value as &A.
Generated from os/cl/catalog/ELSE.json and os/cl/help/ELSE.json.