Flow Control
There are a number of statements that can affect the flow of statement execution within a loop. In addition to the statements listed here, return and pass statements will terminate execution of a repeat loop (see Messages).
On this page:
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.
Exit Repeat
Terminates execution of the current (innermost) repeat loop. Script execution proceeds with the next statement following end repeat.
Exit Handler
Terminates execution of the current handler, returning immediately to the handler that called it. This may also take the form exit handlerName where handlerName is the name of the current handler, or exit on, exit function, exit getProp, or exit setProp to exit from the corresponding type of handler. For more information, see Exit Handler below.
Exit All
Terminates execution of the current handler, the handler that called it, and all other handlers further up the call stack.
Exiting a Handler
Exit Handler
Behavior: Terminates execution of the current handler. Execution continues in the calling handler.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
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:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
exit all
Passing Messages
Pass Command
Behavior: Passes the current message along to the next object in the message passing path (as described in the previous section). This terminates execution of the current handler.
Syntax:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
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:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
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:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
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:
Syntax definitions for language elements follow these formatting guidelines:
- boldface: Indicates words and characters that must be typed exactly
- italic: Indicates expressions or other variable elements
- {} (curly braces): Indicate optional elements.
- [] (square brackets) separated by | (vertical pipes): Indicate alternative options where one or the other can be used, but not both.
Example syntax:
In this example, "open file" is required and must be typed exactly. "fileName" is a variable element; it is the path to and name of the file being opened. The following expression is optional and indicates why the file is being opened. If this expression is added, "for" is required and must be typed exactly. One of the following must be included, but only one, and they also must be typed exactly: "reading", "writing", "readwrite", "appending", or "updating".
Example:
pass original message to alterEgo