dispatch usage versus send
I am trying to figure out the 'correct' use of dispatch: I first set up a lot of details in an iOS app on launch. I load some text files and populate some custom props for use throughout the app. After that I want to load the appropriate fields and other aspects of the app from those custom props BUT only if everything else loaded. I won't know what the data is so I can't check that, I can only tell wether or not something was loaded. I was trying to determine if I should use send or dispatch. 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 But I could use: send loadAllUsers to card Users of this stack send loadCurrentUser to card Users of this stack send loadCurrentUserForm to card Users of this stack My question is Is the right usage of dispatch? Is there another 'better' way to accomplish this? Thanks Tom -- Tom McGrath III http://lazyriver.on-rev.com mcgra...@mac.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: dispatch usage versus send
Thomas McGrath III mcgrath3@... 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 mwie...@ahsoftware.net ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode