While statements
Bananattack edited this page May 8, 2011
·
8 revisions
The Language Reference - While Statements
While statements provide a convenient way to generate to write loops that execute a loop as long their condition is true. They have the form while condition then ...statements end
, where condition is an argument, similar to one that could be passed to [[goto ... when |Branches]]
, and statements consist of the code to execute as long as the condition is true.
x: get #30
while not zero then
x: dec
end
// This code is equivalent to the above, except that the labels are completely private in the former.
x: get #30
begin
def while_loop:
goto end_while when zero
begin
x: dec
end
goto while_loop
def end_while:
end
If you prefer, you can use do
instead of then
after the while
condition:
x: get #30
while not zero do
x: dec
end