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 topic collection in the Programming category in the IBM i Information Center at http://www.ibm.com/systems/i/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.
To test if a pointer has a null value, the CL pointer variable can be compared to the special value *NULL if the CL source is being compiled with the Create CL Module (CRTCLMOD) or Create Bound CL Program (CRTBNDCL) command. If the CL source is being compiled with the Create CL Program (CRTCLPGM) command, compare the CL pointer variable to another CL pointer variable that was declared with ADDRESS(*NULL) and has not been changed.
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 |