CL Command Reference - DOWHILE

CL Command List > DOWHILE Reference

Description:

The Do While (DOWHILE) command evaluates a logical expression and conditionally processes CL procedure commands according to the evaluation of the expression. If the logical expression is true (a logical 1), the commands in this Do While group are processed as long as the expression continues to evaluate to TRUE. If the logical expression evaluates to false (a logical 0), control passes to the next command following the associated ENDDO command.

Restrictions:

. This command is valid only within a CL procedure.

. Up to 25 levels of nested DO, DOWHILE, DOUNTIL, and DOFOR commands are allowed.



Examples:

Example 1: DOWHILE Command Group That is Never Processed

DCL VAR(&LGL) TYPE(*LGL) VALUE(กฏ0กฏ) /* False */
:
DOWHILE COND(&LGL)
: (group of CL commands)
ENDDO

The group of commands between the DOWHILE and ENDDO will not be processed because the initial value of &LGL is false. Control will pass to the command following the ENDDO.



Example 2: DOWHILE Forever Command Group

DCL VAR(&LGL) TYPE(*LGL) VALUE(กฏ1กฏ) /* True */
:
DOWHILE &LGL
: (group of CL commands)
ENDDO

The group of commands between the DOWHILE and ENDDO will be processed until the value of &LGL is set to false (a logical 0). This loop will continue until a LEAVE command or a GOTO command specifying a label outside the DOWHILE group is run.