Building a library with functions with callbacks

Dave Cragg dcragg at lacscentre.co.uk
Mon Jul 11 18:52:26 EDT 2005


On 11 Jul 2005, at 23:08, Alex Tweedly wrote:

>
> I'm sure I've done this before, but can't remember where, and can't  
> figure out how to do it again.
> Sigh :-(      Another CRAFT day :-)
>
> I want to build a library where some of the functions in it have  
> parameters which are callbacks;
>   agtMyFunction pData, pCallBackMessage
>
> the functions will return immediately, and later when the right  
> circumstances exist, the library will send pCallBackMessage to the  
> object which called the library.
> (i.e. just like the callbacks on the socket library).
>
> How do you find which object *called* the library ?  (not "target 
> ()" - that's the object that originally received a message - if its  
> script has called a handler in, say, the card script and that calls  
> the library, then I need to find the card, not the original object)
>

The target will probably work if (using your card script example) the  
target object calls the card script handler using the normal message  
hierachy. So if the callback is sent from the library to the target,  
and there is no handler in the target, it will pass to the card.


Otherwise, I think you have to specify in a parameter the object  
where the handler is.

CRAFT ? I had to look this up because I couldn't remember what it  
stood for. :-)

Cheers
Dave




More information about the use-livecode mailing list