DO command (PL/I)

The DO command allows one or more commands to be collected into a group that can (optionally) be repeatedly executed. The DO and END keywords delimit a group of commands collectively called a DO group. The keywords cannot be abbreviated.

Simple
Read syntax diagramSkip visual syntax diagram
>>-DO--;--+-------------+--END--;------------------------------><
          | .---------. |           
          | V         | |           
          '---command-+-'           

command
A valid Debug Tool command.
Repeating
Read syntax diagramSkip visual syntax diagram
>>-DO----------------------------------------------------------->

>--+-WHILE--(--expression--)--+-------------------------+-+----->
   |                          '-UNTIL--(--expression--)-' |   
   '-UNTIL--(--expression--)--+-------------------------+-'   
                              '-WHILE--(--expression--)-'     

>--;--+-------------+--END--;----------------------------------><
      | .---------. |           
      | V         | |           
      '---command-+-'           

WHILE
Specifies that expression is evaluated before each execution of the command list. If the expression evaluates to true, the commands are executed and the DO group begins another cycle; if it evaluates to false, execution of the DO group ends.
expression
A valid Debug Tool PL/I Boolean expression.
UNTIL
Specifies that expression is evaluated after each execution of the command list. If the expression evaluates to false, the commands are executed and the DO group begins another cycle; if it evaluates to true, execution of the DO group ends.
command
A valid Debug Tool command.
Iterative
Read syntax diagramSkip visual syntax diagram
                     .-,-------------.                       
                     V               |                       
>>-DO--reference--=----| iteration |-+--;--+-------------+------>
                                           | .---------. |   
                                           | V         | |   
                                           '---command-+-'   

>--END--;------------------------------------------------------><

iteration

|--expression--+------------------------------------+----------->
               +-BY--expression--+----------------+-+   
               |                 '-TO--expression-' |   
               +-TO--expression--+----------------+-+   
               |                 '-BY--expression-' |   
               '-REPEAT--expression-----------------'   

>--+------------------------------------------------------+-----|
   +-WHILE--(--expression--)--+-------------------------+-+   
   |                          '-UNTIL--(--expression--)-' |   
   '-UNTIL--(--expression--)--+-------------------------+-'   
                              '-WHILE--(--expression--)-'     

reference
A valid Debug Tool PL/I reference.
expression
A valid Debug Tool PL/I expression.
BY
Specifies that expression is evaluated at entry to the DO specification and saved. This saved value specifies the increment to be added to the control variable after each execution of the DO group.

If BY expression is omitted from a DO specification and if TO expression is specified, expression defaults to the value of 1.

If BY 0 is specified, the execution of the DO group continues indefinitely unless it is halted by a WHILE or UNTIL option, or control is transferred to a point outside the DO group.

The BY option allows you to vary the control variable in fixed positive or negative increments.

TO
Specifies that expression is evaluated at entry of the DO specification and saved. This saved value specifies the terminating value of the control variable.

If TO expression is omitted from a DO specification and if BY expression is specified, repetitive execution continues until it is terminated by the WHILE or UNTIL option, or until some statement transfers control to a point outside the DO group.

The TO option allows you to vary the control variable in fixed positive or negative increments.

REPEAT
Specifies that expression is evaluated and assigned to the control variable after each execution of the DO group. Repetitive execution continues until it is terminated by the WHILE or UNTIL option, or until some statement transfers control to a point outside the DO group.

The REPEAT option allows you to vary the control variable nonlinearly. This option can also be used for nonarithmetic control variables, such as pointers.

WHILE
Specifies that expression is evaluated before each execution of the command list. If the expression evaluates to true, the commands are executed and the DO group begins another cycle; if it evaluates to false, execution of the DO group ends.
UNTIL
Specifies that expression is evaluated after each execution of the command list. If the expression evaluates to false, the commands are executed and the DO group begins another cycle; if it evaluates to true, execution of the DO group ends.
command
A valid Debug Tool command.

Usage note

You cannot use the DO command while you replay recorded statements by using the PLAYBACK commands by using the PLAYBACK command.

Examples