Repeat statement0


SYNTAX:
repeat_stmt = REPEAT repeat_control ';' stmt { stmt } END_REPEAT ';' .
repeat_control = [ increment_control ] [ while_control ]  [ until_control ] .
increment_control = variable_id ':=' bound_1 TO bound_2 [ BY increment ] .
bound_1 = numeric_expression .
bound_2 = numeric_expression .
increment = numeric_expression .
The repeat statement is used to conditionally repeat the execution of a sequence of statements. Whether the repetition is started or continued is determined by evaluating the control condition(s). The control conditions are:
finite iteration;
while a condition is true ;
until a condition is true .
These controls can be used in combination to specify the conditions that terminate the repetition. These conditions are evaluated as follows to control the iterations:
Upon entering the repeat statement, the increment control statement, if present, is evaluated as described in 13.9.1. in ISO 10303-11.
The while_control expression, if present, is evaluated. If the result is true (or no while control exists), the body of the repeat statement is executed. If the result is false or unknown the execution of the repeat statement is terminated.
When the execution of the body of the repeat statement is complete, any until control expression is evaluated. If the resulting value is true the iteration stops and the execution of the repeat statement is complete. If the result is false or unknown the control of the repeat statement is returned to the increment control. If no until control is present, the control is returned to the increment control.
If increment control is present, the value of the loop variable is incremented by increment. If the loop variable is between bound_1 and bound_2, including the bounds themselves, control passes to (b) above, otherwise the execution of the repeat statement is terminated.
example:
(*
This example shows how more than one controlling condition can be used in a repeat statement. The statement iterates until either the desired tolerance is achieved, or one hundred cycles, whichever occurs first; i.e., iteration stops when the solution does not converge fast enough.
*)
 
REPEAT i:=1 TO 100 UNTIL epsilon < 1.E-6;
...
 epsilon := ...;
END_REPEAT;