|
|||||
|
|||||
Related Syntax | |||||
control structure |
repeat, again, exit |
Syntax
repeat local-declaration* action* exit? condition? again
repeat
is used to create a loop. All actions between repeat
and again
are repeated until the loop is terminated by an exit
statement. Execution then resumes after the again
.
A repeat loop constitutes a local scope, so local variables declared within the loop are local to the loop. In fact, they are local to each iteration of the loop, which means their values are re-initialized on each iteration. They are not, therefore, good candidates for creating exit conditions or maintaining data across iterations of the loop. In the following program, the output shows the value of "i" going up each time, but the value of "j" staying the same:
process local integer i repeat local integer j output "i=%d(j) : j=%d(i)%n" increment i increment j exit when i > 20 again
Within a function you can use return
instead of exit to terminate a loop so that:
function ... repeat ... exit when x > 5 again return ycan be replaced by:
function ... repeat ... return y when x > 5 again
Related Syntax |
Copyright © Stilo International plc, 1988-2010.