Error getting tags :
error 404Error getting tags :
error 404 dispatch | revDocs | RunRev
Welcome Guest (Log in)
Product Edition
Expander triangle

dispatch message [ to target ][ with argumentList ]

Desktop, Web and Server
Platform Support
Mac OS X,Windows,Linux
None required
Sends a message to an current object via the normal message path

dispatch "updateWidget"
dispatch "setList" with tNewList

Additional Comments
Expander triangle

Use the dispatch command to send a mesage to an object, via the message path and find out whether it was handled or not.


The message is an expression that evaluates to the name of a handler.

The target is a reference to any Revolution object.

The argumentList is a comma separated list of expressions containing the arguments to send.


The dispatch command is most useful when using behaviors, as it allows a behavior script to send an 'event' to one of its child objects and then perform an action depending on the outcome.

Executing a dispatch command causes the message to be sent to the target object with the given argument list. This message passes through the message path in the normal way. Once finished, the variable 'it' will contain one of the following three values:

"handled" - the message was handled and not passed

"unhandled" - no matching handlers were found

"passed" - the message was handled but passed by all handlers

If no target is specified, the message is sent to 'me'. Note that in the context of a behavior, this will typically be the child that is executing rather than the behavior object itself.

User Comments
Expander triangle
User thumbnail
Oliver Kenyon
Jan 29, 2009
Be careful to ensure when using dispatch recursively that an infinite loop won't be caused. For example something like this will never terminate unless a child handles the message:

command updateView
dispatch "updateView"
end updateView

This applies equally to the send and call commands.
User thumbnail
Phil Davis
Mar 5, 2010
You can also use the dispatch command to dispatch functions.

dispatch function "getValue" to button 2 with theParam
put the result into tValueReturnedFromFunction
put it into tHandledStatus

User thumbnail
Mark Schonewille
Dec 16, 2010
You can obtain the same result using the send command insude a try control structure:
put "something" into var1 put "something else" into var2 try send "someCommand var1,var2" to this cd in 100 millisecs end try
This allows you to "dispatch" a command after a delay or after the current handler has finished and makes it easier to include paramters.
User thumbnail
Peter Brigham
Dec 22, 2010
It appears that the dispatch command works only for user-scripted handlers or functions, eg, trying: dispatch "go next" to this cd; put it yields "unhandled".