while (condition) { statement1; statement2; ... }
The while statement checks the condition, and if it’s true, executes the block, then repeats. As long as the condition is true, the block continues to execute.
float $test = 0; while ($test < 5) { print("$test equals: " +$test+"\n"); $test = $test + 1; }
This example prints the following lines in the Script Editor:
$test equals: 0 $test equals: 1 $test equals: 2 $test equals: 3 $test equals: 4
If you write a script that has an infinite loop in it (usually within a while statement), there is no way to interrupt it without stopping Maya (for example, from the Task Manager on Windows).
Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License