"send" vs "dispatch"

Geoff Canyon gcanyon at gmail.com
Fri Oct 5 18:08:29 EDT 2018


A word to the wise (mostly for IDE and extension developers): this will
successfully compile:

   send "test" to button 1 with "ha"

And then if the IDE is swallowing up your error messages (as it does for
extensions like Navigator) it will even deliver the message "test" to
button 1, just without any arguments, and then die silently.

Outside of "rev" stacks, it will deliver the message without arguments and
then throw an error saying there is no handler "with". I just checked, and
amazingly this will work:

on mouseUp
   send "test" to button 1 with "ha"
end mouseUp

on with
   answer "WTH?"
end with

But that's obviously unlikely. Far more likely if you're dealing with
code you wrote before you became aware of "dispatch" (or maybe before
"dispatch" was a thing -- I think Navigator predates LC 3.5) is that you
decide to add an argument to a remote call and don't notice that it's a
"send" rather than a "dispatch", and then spend half an hour trying to
figure out why your arguments aren't passing through <grumble>.



More information about the use-livecode mailing list