Call and Send?
J. Landman Gay
jacque at hyperactivesw.com
Thu Dec 8 21:18:13 EST 2005
Steven Fernandez wrote:
> Thanks for the pointer. What I found in that article is:
> "The difference between the send and call commands is that the send
> command changes the context so that object references are treated as
> relative to the object you send the message to, while the call command
> does not change the context and continues to treat object references
> relative to the original object."
> Looking back at the docs I now see this mentioned with an example on
> the send help help page.
Maybe you already know this, but just in case: note that you don't need
either of these commands except in unusual circumstances. If you only
want your messages to get "caught" you don't need to either send or call
them. Just issue them and they will be passed through the message path
normally. For example:
answer "I did it."
That's all there is to it; issuing "doIt" automatically pushes it
through the message path. Because the "doIt" handler is in the same
object script, it gets caught. It could also be in any other script
"downstream" in the hierarchy and it would get caught just as well.
You only need to "send" a message if the handler you're sending is
located somewhere else in the path where it won't normally be seen. For
example, if "myTest" is in the stack script and "doIt" is in the card
script, you'd need to "send 'doIt' to this card" because the card script
is "upstream" from the stack script, opposite the normal message flow.
One other reason to use "send" is to create timers, but it doesn't sound
like you're doing that.
I've been using xtalk for 20 years and I've not needed "call" yet. Maybe
I'm missing something.
Jacqueline Landman Gay | jacque at hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
More information about the Use-livecode