主题:  第四部分第十二条细

吃鱼专家

职务:普通成员
等级:6
金币:11.0
发贴:5312
#12002/1/8 15:53:21
end repeat

参见:
repeat while, repeat with, repeat with...in list, repeat with...down to



repeat while

语法

repeat while testCondition
        statement(s)
end repeat

描述

关键字;重复执行statement(s)只要条件规定testCondition为真。这结构能使用Lingo来继续读入字符串直到文件到达未端,检查项目延伸到列表结束位,或重复执行动作直到用户点击或者释放鼠标。

点击当前的循环及使用相应的快捷键后,在重复循环时,Lingo会忽视其它事件。

只有操作者可以控制时间。如果Lingo在重复循环时花了长时间,其他的事件会加起来估算。因此,重复循环最好在短、快操作或当使用者空闲时使用。

如果你需要过程大约几秒或更多,估算一些类型的计数器循环或测试轨迹前进的函数。

用JAVA的Director播放器无法检测鼠标运动、更新出现的位置或鼠标按键状态。

如果到不到停止条件或从重复循环中没有退出,你可以顺便在Director用Control+Alt+节点(Windows)或Command+节点(Macintosh)。

例题

操作员开始计时,重新安排计时器到0,于是计时器通过60下:

on countTime
    startTimer
    repeat while the timer < 60
    -- waiting for time
    end repeat
end countTime

参见
exit, exit repeat, repeat with, keyPressed()

编辑历史:[这消息被mb1978编辑过(编辑时间2002-01-08 15:56:11)]


吃鱼专家

职务:普通成员
等级:6
金币:11.0
发贴:5312
#22002/1/8 15:57:48
上面的原文:

repeat while

Syntax

repeat while testCondition
        statement(s)
end repeat
Description

Keyword; repeatedly executes statement(s) so long as the condition specified by testCondition is TRUE. This structure can be used in Lingo that continues to read strings until the end of a file is reached, checks items until the end of a list is reached, or repeatedly performs an action until the user presses or releases the mouse button.

While in a repeat loop, Lingo ignores other events. To check the current key in a repeat loop, use the keyPressed property.

Only one handler can run at a time. If Lingo stays in a repeat loop for a long time, other events stack up waiting to be evaluated. Therefore, repeat loops are best used for short, fast operations or when users are idle.

If you need to process something for several seconds or more, evaluate the function in a loop with some type of counter or test to track progress.

The Director player for Java doesn't detect mouse movements, update properties that indicate the mouse's position, or update the status of mouse button presses when Lingo is in a repeat loop.

If the stop condition is never reached or there is no exit from the repeat loop, you can force Director to stop by using Control+Alt+period (Windows) or Command+period (Macintosh).

Example

This handler starts the timer counting, resets the timer to 0, and then has the timer count up to 60 ticks:

on countTime
    startTimer
    repeat while the timer < 60
    -- waiting for time
    end repeat
end countTime
See also

exit, exit repeat, repeat with, keyPressed()


要不要翻下去?