Passing control away and back again

J. Landman Gay jacque at hyperactivesw.com
Sun Feb 15 11:55:58 EST 2015


On February 15, 2015 10:41:42 AM CST, Paul Dupuis <paul at researchware.com> wrote:
>On 2/15/2015 10:02 AM, Graham Samuel wrote:
>> But I do understand Paul's, which was very near the approach I was
>thinking of taking myself. I suppose I am still worried about the
>'send'. Sending isn't calling, is it? I mean, in principle, a handler
>like "dopart2" in Paul's example will be executed, and then control
>will return to the script that executed the 'send', won't it? So we end
>up executing "end mouseUp" in the context of the button that was
>clicked, not the script that was running in the 'startUp' handler.
>Perhaps this doesn't matter, but this is the issue I'm trying to get my
>head around. Anyway it's a viable solution and I'm grateful.
>
>send <message> to <object> -- is like a call. The handler waits until
>message is executed before proceeding to the next statement
>
>send <message> to <object> in <time> -- places the message in the
>message queue and the handler continues. The message queue then invokes
>the message in the allotted time.
>
>So,
>
>on mouseUp
>  close this stack
>  send "doPart2" to <main stack>
>end mouseUp
>
>will not do what you want as the send executes "doPart2" and the
>completes the mouseUp, but
>
>on mouseUp
>  close this stack
>send "doPart2" to <main stack> in 10 milliseconds -- or some non-zero
>time
>end mouseUp
>
>causes doPart2 to execute in the context of the main stack AFTER the
>mouseUp handler has completed.
>
>If I recall correctly, Richard Gaskin produced an excellent short 1 or
>2
>page guide on message passing in LiveCode. A *must have* reference if
>you're still learning all the ins and outs. It looks like he's expanded
>it from the one I remember as well. See
>http://www.fourthworld.com/embassy/articles/revolution_message_path.html
>
>
>_______________________________________________
>use-livecode mailing list
>use-livecode at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-livecode

Actually you can send in 0, which will execute right after the handler completes, or even in - 1 which pushes the request to the front of the queue ahead of all other pending messages. I learned that last trick from Dar a while back. 
-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list