The DO WHILE statement causes the statements in the DO-group to be executed in a loop, provided the condition specified in the test expression is satisfied. When the condition is not true, the statements in the DO-group are not executed, and control passes to the statement following the END statement.
Execution of a DO WHILE statement causes the test expression to be evaluated to produce a value b, which must be a bit-string of length greater than or equal to one.
The test expression will be considered true if any of the bits in the string are one, and will be considered false only when all bits are zero.
If b is true, the statements of the group are executed; when the corresponding END statement is executed, control is transferred back to evaluate the test expression again, and the new value of b is tested. If b is false, the statements in the group are not executed, and execution resumes with the statement following the END statement.
The DO UNTIL statement causes a group of statements to execute until a certain condition is satisfied. As long as the condition is false, the group is repeated.
The test-expression is evaluated after each execution of the DO-group. For the DO-group to be repeated, the expression must have a false value. If the expression has a true value, control passes to the next executable statement following the END statement that terminates the DO-group.
The DO UNTIL option resembles the DO WHILE option, in that both options evaluate the status of test expressions; however, the DO WHILE option checks the test expression's value at the beginning of the DO-group, whereas the DO UNTIL statement checks its value at the end of the DO-group. Consequently, a DO-group containing a DO UNTIL statement with no WHILE clause will always be executed at least one time, but a DO-group containing a DO WHILE statement may never be executed.
Example
DO WHILE(EOF = 0);/* an end of file ON-unit sets EOF = 1 */
READ FILE(F) INTO(REC);
END;
DO UNTIL(B = 1);
ARRAY(B) = B;
B = B - 1;
END;
DO WHILE(EOF = 0) UNTIL(SUBSTR(REC,1,6) = 'marker');
READ FILE(F) INTO(REC);
END;
Description
The DO WHILE statement causes the statements in the DO-group to be executed in a loop, provided the condition specified in the test expression is satisfied. When the condition is not true, the statements in the DO-group are not executed, and control passes to the statement following the END statement.
Execution of a DO WHILE statement causes the test expression to be evaluated to produce a value b, which must be a bit-string of length greater than or equal to one.
The test expression will be considered true if any of the bits in the string are one, and will be considered false only when all bits are zero.
If b is true, the statements of the group are executed; when the corresponding END statement is executed, control is transferred back to evaluate the test expression again, and the new value of b is tested. If b is false, the statements in the group are not executed, and execution resumes with the statement following the END statement.
The DO UNTIL statement causes a group of statements to execute until a certain condition is satisfied. As long as the condition is false, the group is repeated.
The test-expression is evaluated after each execution of the DO-group. For the DO-group to be repeated, the expression must have a false value. If the expression has a true value, control passes to the next executable statement following the END statement that terminates the DO-group.
The DO UNTIL option resembles the DO WHILE option, in that both options evaluate the status of test expressions; however, the DO WHILE option checks the test expression's value at the beginning of the DO-group, whereas the DO UNTIL statement checks its value at the end of the DO-group. Consequently, a DO-group containing a DO UNTIL statement with no WHILE clause will always be executed at least one time, but a DO-group containing a DO WHILE statement may never be executed.