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 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. This
can be used to run a loop a specified number of times without needing
a separate iteration variable; e.g. <while $loop lt 10>...</while>
will run 10 times.
SEE ALSOIF
, BREAK