How does a command find out who called it?
andre at andregarzia.com
Wed Feb 1 17:44:48 CST 2012
The way I implement such callbacks is by using a script local
variable. In my script local variable, I have a handler that registers
a callback. This handler will keep track of the target that registered
the callback. When I need to send a callback later, I pick the
original target from that variable.
I've edited the original code below:
The stack script says:
start using "minihttp.livecode"
The card script says:
on someHandler ...
on myCallback ...
-- do someting brilliant with the data we've requested
Finally, I have a stack called "minihttp.livecode".
The stack script looks like:
on httpGet pUrl,pCallback
-- save the callback
put the target into sCallbackA["target"]
put pCallback into sCallbackA["message"]
-- kick off asynchronous httpGet operations with a local callback
-- now return
on mySocketCallback args
-- Yay! Finally have the data. Hand it back
send sCallbackA["message"] to sCallbackA["target"] in 0 milliseconds
More information about the use-livecode