Skip to main content
Version: 23.5

Flow Control

There are a number of statements that can affect the flow of statement execution within a script.

Changing the Flow of a Repeat Loop

In addition to the statements listed here, return and pass statements will terminate execution of a repeat loop (see Messages).

Next Repeat

Causes any statements following the next repeat statement, down to the end repeat, to be skipped and execution to jump directly back to the beginning of the current (innermost) repeat loop. Execution then continues with the next iteration.

Syntax:
next repeat

Exit Repeat

Terminates execution of the current (innermost) repeat loop. Script execution proceeds with the next statement following end repeat.

Syntax:
exit repeat

Exiting a Handler

Exit Handler

Behavior: Terminates execution of the current handler. Execution continues in the calling handler.

Syntax:
exit handlerOrFunctionName
exit [handler | script | on | function | getProp | setProp]

note

If handlerOrFunctionName or a handler type is given, it must match the name or type of the current handler.

Examples:

exit handler
exit myFancyFunction

Exit All, Exit to Top

Behavior: Stops execution of all handlers (the current handler, plus the handler which called it, and so forth).

Syntax:
exit all
exit to [top | SenseTalk]

Example:

exit all

Passing Messages

Pass Command

Behavior: Passes the current message along to the next object in the message passing path (as described here). This terminates execution of the current handler.

Syntax:
pass handlerOrFunctionName
pass {the} message

note

If handlerOrFunctionName is given (rather than the generic term “message”), the name supplied must be the same as the name of the current handler.

Example:

pass message

Pass ... and Continue Command

Behavior: Use the pass ... and continue command to pass the current message along to the next object in the message passing path, just as the pass command does, but allow the current handler to continue running after the message has been handled elsewhere.

The current handler resumes executing after the message is handled by some other object later in the message passing path. Any value returned by the other object is available in the result immediately after the pass ... and continue command.

After executing a pass ... and continue command, any later attempt to pass that message (using any of the pass commands) will be unable to actually pass the message along, as no message is ever delivered to the same object twice.

Syntax:
pass handlerOrFunctionName and continue
pass {the} message and continue

Examples:

pass message and continue

Pass ... Without Helping Command

Behavior Use pass ... without helping to pass the message along to the next object following the helpee in the message passing path. This differs from the pass command when used in a helper. In essence, the helper is saying “I’m not able to help with this message”. The helpers’ helpers are not given a chance to handle the message, but the message is passed to later helpers of the object being helped, and to other objects later in the message passing path.

The current handler stops running when this command is executed.

Syntax:
pass handlerOrFunctionName without helping
pass {the} message without helping

Example:

pass message without helping

Pass Original Message To ... Command

Behavior: Use pass original message to ... to pass the current message directly to some other object. This differs from other forms of the pass command, which pass the current message along to the next object in the message passing path.

This form of the pass command is intended for use within undeliveredMessage handlers to try passing the original (undelivered) message to some other object for handling. If that object handles the message, that will be the end of it, and execution of the current handler will end. If the other object does not handle the message, execution will continue in the current handler. In this way an undeliveredMessage handler can attempt to deliver the original message to one or more other objects which may be able to handle it. For more information, see Handling Undelivered Messages.

If and continue is specified, the current handler resumes executing after the message is passed, whether or not it was handled by the other object.

Syntax:
pass original message to object {and continue}

Example:

pass original message to alterEgo