Where allowed to run:
|
Parameters Examples Error messages |
The Do Until (DOUNTIL) command processes a group of CL commands one or more times. After the commands in the group have been processed, the logical condition is evaluated.
If the logical expression is false (a logical 0), the commands in this Do Until group are processed again for as long as the expression continues to evaluate to false. If the logical expression evaluates to true (a logical 1), control passes to the next command following the associated ENDDO command.
Restrictions:
Top |
Keyword | Description | Choices | Notes |
---|---|---|---|
COND | Condition | Logical value | Required, Positional 1 |
Top |
Specifies the logical expression that is evaluated to determine a condition in the program and whether the loop is processed again. Refer to "Logical Expressions" in the CL concepts and reference topic in the iSeries Information Center at http://www.ibm.com/eserver/iseries/infocenter for a description of logical expressions. Note that variables, constants, and the %SUBSTRING, %SWITCH, and %BINARY built-in functions can be used within the expression.
This is a required parameter.
Top |
Example 1: DOUNTIL Command Group
DCL VAR(&INT) TYPE(*INT) LEN(2) VALUE(10) : DOUNTIL COND(&INT *GT 100) : (group of CL commands) CHGVAR VAR(&INT) VALUE(&INT + &VAL) ENDDO
The group of commands between the DOUNTIL and ENDDO will be processed until the value of &INT is greater than 100 when the ENDDO command is processed. The contents of the DOUNTIL group will be processed at least once regardless of the value of &INT at the beginning of the group.
Example 2: DOUNTIL Forever Command Group
DOUNTIL COND('0') : (group of CL commands) ENDDO
The group of commands between the DOUNTIL and ENDDO will be processed until either a LEAVE or GOTO command is encountered.
Top |
None
Top |