Usage:
/WHILE (expr)
list /DONE
/WHILE list
/DO list
/DONE
The lists may be any list of commands. The return value of a list is the return value of the last command executed in the list. Each list must be terminated by "%;".
The list or expr following the /WHILE is called the condition. The condition is executed or evaluated, and if its result is non-zero, the next list is executed. This sequence is repeated until the condition returns zero.
The /BREAK command can be used within the loop to terminate the loop early. The loop can also be terminated early by catching a SIGINT (usually generated by typing ^C). If the variable %{max_iter} is non-zero, the loop will terminate automatically if the number of iterations reaches that number.
When /WHILE is used on the command line, "%;" command separation will be done even if %sub=off. Of course, full substitution will be done if %sub=full.
Example:
/def count = \ /let i=1%; \ /while (i <= {1}) \ say %{i}%; \ /let i=$[i + 1]%; \ /done
The command "/count 10" will execute the commands "say 1", "say 2", ... "say 10".
See: evaluation, /test, /break, /for