dispatch usage versus send

Mark Wieder mwieder at ahsoftware.net
Fri Jul 26 13:53:53 EDT 2013


Thomas McGrath III <mcgrath3 at ...> writes:

> I am using this code now:
> 
> on openstack
> loadCustomPropsFromFile
> dispatch "loadAllUsers" to card "Users" of this stack
>      if it is "handled" then
>           dispatch "loadCurrentUser" to card "Users" of this stack
>           if it is "handled" then
>                dispatch "loadCurrentUserForm" to card "Users" of this stack
>           end if
>      end if
> end openstack

> My question is "Is the right usage of dispatch?"

Not in terms of what you're trying to accomplish. The "handled" result says
that there was a handler somewhere in the message path that caught the
message and processed it. It's not an indication that the loadxxx command
was successful. To do that you'd need to return a value in the result or set
a semaphore somewhere or some similar action.

You'd be in the same situation if you used "send". Lately I've taken to
using send only when I need to send a message in time, and I'm using
dispatch for all other situations. There are some subtle differences in
context, but otherwise you can treat them the same. And "dispatch function"
is a lot easier to read, remember, and maintain than the "value(..." syntax.

-- 
 Mark Wieder
 mwieder at ahsoftware.net







More information about the use-livecode mailing list