repeat Full Description |
|
Syntaxrepeat local-declaration* action* exit? condition? again Purpose
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 reinitialized on each iteration. They are not, therefore, good candidates for creating exit conditions or maintaining data across iterations of the loop. In the follwing program, the output shows the value of "i" going up each time, but the value of "j" staying the same:
process local counter i repeat local counter j output "i=%d(j) : j=%d(i)%n" increment i increment j exit when i > 20 again Within a function you can use function ... repeat ... exit when x > 5 again return ycan be replaced by: function ... repeat ... return y when x > 5 again |