WHILE - conditional loop

 

SYNOPSIS

<WHILE condition>
  ... statements ...
</WHILE>


DESCRIPTION
The WHILE statement loops over its statements as long as the given condition is true. $loop is set to 0 before the loop is started, and is incremented at the bottom of every iteration. The condition has the same syntax as for IF.

A BREAK statement, if encountered, will exit the loop.


EXAMPLE
This example prints 10 image tags, for a bar graph:

<WHILE $loop lt 10>
  <IMG SRC=/icons/bar.gif BORDER=0>
</WHILE>


CAVEATS
The WHILE statement was added Feb. 6 1997.

An infinite loop can be created, if the condition is never false. Similarly, if the condition is never true, the loop is never executed.

Unlike most other looping statements, $loop is set before the WHILE condition is first executed, so it always has the loop's value and not its previous value when the condition is tested.


SEE ALSO
IF, BREAK


Copyright © Thunderstone Software     Last updated: Sep 25 2019
Copyright © 2019 Thunderstone Software LLC. All rights reserved.