Dispatch Versus Send
zryip theSlug
zryip.theslug at gmail.com
Thu Mar 4 16:59:38 EST 2010
2010/3/4 Gregory Lypny <gregory.lypny at videotron.ca>:
> Hello everyone,
>
> What's the difference between the two other than Dispatch using the normal
> message path?
Hello Gregory,
The disptach definition from the Rev dictionary:
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.
The send message in the rev dictionary:
Use the send command to override the normal message path, or to delay
a command until a specified time.
In conclusion,
1) Dispatch
- is recommended with behavior.
- provide you a result if the message has been intercepted or not
(handled, unhandled or passed)
2) send
- allow you to override the normal message path. You'll be obtain an
error if the message is not intercepted by an object (ie if you send a
customMessage to a cd, you will obtain an error message if the
customMessage doesn't exists in the card script).
- allow you to delay a command (ie for scanning some events, creating
animations, etc)
HTH,
--
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc
More information about the use-livecode
mailing list