Dispatch vs Libraries

Todd Geist todd at geistinteractive.com
Sun Nov 27 15:27:32 EST 2011


On Sun, Nov 27, 2011 at 10:41 AM, Pete <pete at mollysrevenge.com> wrote:

Something looks a little strange about the first dispatch statement -
> you're sending a message to an array? I thought messages went to
> stacks/cards/controls.  I think you'd also need to use the "dispatch
> function" syntax to get a result back.


Hi Pete,

It works. You don't need to use the function syntax unless of course it is
a call to a Function that you are dispatching. In the case I cited I am
using a command but the command uses Return to return the result.

When you do it that way,  you get the returned value in "the result".  And
"it" contains "handled", "unhandled", or "passed"

And the arrayElement just contains the long id of the control that I am
sending the message to. I set it like this

put the long id of button "Contacts" into Services["Contacts"]


Since Services is Global I can now dispatch a message to that Control from
anywhere like so

dispatch "Message" to Services["Contact"] with param1, param2, param3


This seem very readable to me.


Todd


-- 
Todd Geist
geist interactive
(805) 419-9382



More information about the use-livecode mailing list