A related function is While(), which repeatedly tests the condition and evaluates its body script as long as the condition is true. The syntax is:
While( condition, body );
For example, here are two different programs that use a While() loop to find the least power of 2 that is greater than or equal to x (287). The result of both programs is 512.
x = 287;
 
// loop 1:
y = 1;
While( y < x, y *= 2 );
Show( y );
 
// loop 2:
k = 0;
While( 2 ^ k < x, k++ );
Show( 2 ^ k );
x = 287;
Sets x to 287.
// loop 1
y = 1;
Sets y to 1.
While(
Begins the While() loop.
	y < x,
As long as y is less than x, continues evaluating the loop.
	y *= 2
Multiplies 1 by 2 and then assigns the result to y. The loop then repeats while y is less than 287.
);
Show(y);
// loop 2
k = 0;
Sets k to 0.
While(
Begins the While() loop.
	2 ^ k < x,
Raises 2 to the exponent power of k and continues evaluating the loop as long as the result is less than 287.
	k++
Increments k to 1. The loop then repeats while 2 ^ k is less than 287.
);
Show(2 ^ k);
As with For() loops, While() loops that always evaluate as true create an infinite loop, which never stops. To stop the script, press ESC on Windows (or COMMAND-PERIOD on Macintosh). You can also select Edit > Stop Script. On Macintosh, Edit > Stop Script is available only when the script is running.

Help created on 10/11/2018