该帮助的版本不再更新,请参见https://www.jmp.com/support/help/zh-cn/15.2 获取最新的版本.


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:
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;
While( y < x, y *= 2 );
Show( y );
While( 2 ^ k < x, k++ );
Show( 2 ^ k );
Sets x to 287.
Sets y to 1.
Begins the While() loop.
As long as y is less than x, continues evaluating the loop.
Multiplies 1 by 2 and then assigns the result to y. The loop then repeats while y is less than 287.
Sets k to 0.
Begins the While() loop.
Raises 2 to the exponent power of k and continues evaluating the loop as long as the result is less than 287.
Increments k to 1. The loop then repeats while 2 ^ k is less than 287.
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.