Warning

You're browsing the old v2.x documentation. This version is no longer maintained. Click here to go the v3.x documentation.

This is an old revision of the document!


WHILE ... ENDWHILE

Since version 2.1

Syntax:

while <condition>
  <statements>
endwhile

The WHILE command starts a pre-test loop where the given condition is evaluated every time before entering the loop. If the condition evaluates to true, the statements between WHILE and ENDWHILE will be executed and the condition will be tested again . If it evaluates to false, the statements will be skipped and execution will be continued after the ENDWHILE statement.

Example:

print "counting down from ten"
n = 10
while n > 0
  print n
  dec n
endwhile

Note: for a post-test loop, see REPEAT ... UNTIL.