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).

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:

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

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:

pass handlerOrFunctionName
pass {message | on | function | getProp | setProp}
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. If on, function, getProp, or setProp is used, they must match the current handler type.

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 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 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

 

This topic was last updated on August 19, 2021, at 03:30:51 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant