Syntax

Repeats a block as long as a condition is true. The condition is tested before each pass, so the body can run zero times.

WHILE <condition>
  <statements>
ENDWHILE
END WHILE
WEND

Also written : ENDWHILE, WEND, END WHILE

Parts

<condition>Any expression, tested before each pass. 0, an empty string, FALSE and NULL are false.
<statements>The body of the loop.

Good to know

  • ENDWHILE, END WHILE and WEND all close the loop.
  • DO WHILE … LOOP does not exist: DO … LOOP is the frame loop. Write WHILE … ENDWHILE.
  • In a program with no DO loop and no END on its own line, a Sync() inside a WHILE does not wait for the next frame. A "wait for a click" loop then freezes the tab. Add an END line to the program.

Example

n = 1WHILE n < 100  n = n * 2ENDWHILEConsole(Str(n))   ' 128WHILE n > 500  Console("never shown")WEND
In the manual : Control flow