DOUNTIL command

The Do Until (DOUNTIL) command processes a group of CL commands one or more times.

The group of commands is defined as those commands between the Do Until (DOUNTIL) and the matching End Do (ENDDO) command.

After the group of commands is processed, the stated condition is evaluated. If the condition is true, the DOUNTIL group will be exited and processing will resume with the next command following the associated ENDDO. If the condition is false, the group will continue processing with the first command in the group.

The logical expression on the COND parameter may be a single logical variable or constant, or it must describe a relationship between two or more operands; the expression is then evaluated as true or false.

The following is an example of conditional processing with a Do Until (DOUNTIL) command.

DOUNTIL (&LGL)
  .
  .
  .
  CHGVAR &INT (&INT + 1)
  IF (&INT *GT 5) (CHGVAR &LGL '1')
ENDDO

The body of the DOUNTIL group will be run at least one time. If the initial value of the &INT variable is 5 or more, &LGL will be set to true on the first time and processing will continue following the ENDDO when the expression is evaluated at the end of the group. If the initial value is less than 5, the body of the group will continue to be repeated until the value of &INT is greater than 5 and the value of &LGL is changed to true.

The Leave (LEAVE) command may be used to exit the DOUNTIL group and resume processing following the ENDDO. The ITERATE command may be used to skip the remaining commands in the group and evaluate the stated condition immediately.

Related reference
*AND, *OR, and *NOT operators
Related information
CL command finder
Do Until (DOUNTIL) command