Skip to main content

Pausing Script Execution

Script execution can be paused, either to wait for some external condition, or to delay for a specified length of time, using one of the wait statements. You can use the breakpoint command to pause script execution and enter debugging mode.

note

The ask and answer commands will also cause a script to pause while waiting for input from the user.

Wait While, Wait Until Commands

Behavior: The wait until command will pause script execution until a given condition occurs or until a particular date/time arrives. If a time is given which is already in the past, execution proceeds immediately. The wait while command waits until a condition is no longer true. In both commands, the condition expression is evaluated repeatedly, and should be an expression whose value will eventually change to the awaited outcome.

Syntax:
wait while condition
wait until condition
wait until timeExpression

Examples:

wait until "12:50 PM"
wait until temperature(hell) < 32
wait while the sound is not done

Wait Command

Behavior: The wait command will pause script execution for a specified length of time. The script simply goes to sleep for the time interval indicated, then wakes up and continues with executing the following statement.

The timeInterval is any expression that evaluates to a number of seconds. Since SenseTalk supports time interval expressions which evaluate to seconds, you can express the time in a natural fashion, using the terms weeks, days, hours, minutes, seconds, ticks, milliseconds, and microseconds (see Time Intervals). If a time unit is not specified, seconds are assumed.

Syntax:
wait timeInterval

Examples

wait 20 ticks -- 1/3 of a second
wait 2 days 7 hours 14 minutes and 28.6 seconds
wait 3 milliseconds
wait 1.5 -- Assumes seconds, since no unit was specified

Breakpoint Command

Behavior: The breakpoint command, if executed in the context of a debugger, will cause execution of the script to be suspended and control transferred to the debugger. Call breakpoint at any point in your script where you want it to stop for debugging purposes.

note

The breakpoint command has no effect if the script is running in an environment without a debugger. Breakpoints can also be disabled by setting the breakpointsEnabled global property to False. Setting this property to True again (its default value) will reenable breakpoints.

Syntax:
breakpoint

Example:

if count > upperLimit then breakpoint