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.
>>-DO--;--+-------------+--END--;------------------------------>< | .---------. | | V | | '---command-+-'
- command
- A valid Debug Tool command.
>>-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.
.-,-------------. 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
- At statement 25, initialize variable a and display
the values of variables x, y, and z.
AT 25 DO; %BLOCK:>a = 0; LIST (x, y, z); END;
- Execute the DO group until ctr is
greater than 4 or less than 0.
DO UNTIL (ctr > 4) WHILE (ctr >= 0); END;
- Execute the DO group with i having
the values 1, 2, 4, 8, 16, 32, 64, 128, and 256.
DO i = 1 REPEAT 2*i UNTIL (i = 256); END;
- Repeat execution of the DO group with j having
values 1 through 20, but only if k has the value
1.
DO j = 1 TO 20 BY 1 WHILE (k = 1); END;