while
 
 
 

while ループの形式は次のとおりです。

while (condition) {
	statement1;
	statement2;
	...
}

while 文は条件を確認し、true であればブロックを実行し、以降それを繰り返します。条件が true である限り、ブロックは実行され続けます。

float $test = 0;
while ($test < 5) {
	print("$test equals: " +$test+"\n");
	$test = $test + 1;
}

この例では、スクリプト エディタ(Script Editor)には次のように出力されます。

$test equals: 0
$test equals: 1
$test equals: 2
$test equals: 3
$test equals: 4
注:無限ループがあるスクリプトを記述する場合(通常 while 文内)、(たとえば、Windows のタスク マネージャから)Maya を停止することなくスクリプトを中断することはできません。