do...while

 
 
 

do 循环采用以下格式:

do {
	statement;
	statement;
	 ...
} while (condition);

while 循环不同,do...while 循环在每个循环结束时将检查条件。该块将至少执行一次。当条件为 false 时,循环将会终止

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

它将在“脚本编辑器”(Script Editor)中显示以下行:

$test equals: 0
$test equals: 1
$test equals: 2
$test equals: 3
$test equals: 4