Adding `the caller` to LiveCode Script
lists at mangomultimedia.com
Tue Nov 26 10:59:00 EST 2019
About 15 years ago Dar Scott added a feature request to have a function
that returns the long ID of the caller's caller's object:
Two years ago LiveCode Builder added `the caller` which does just that, but
only in LCB. If anyone is looking for a contribution to make to the engine
I am throwing this out there as something to consider: Add `the caller` to
Why is this useful?
When writing handlers that send callback messages it is sometimes desirable
to send the message to the object that called the handler. For example,
let's say I have a library that makes REST calls to a server API. This
calls are asynchronous so a handler in the library will need to notify the
caller that the request is finished. If a handler from the library was
called from a card then I might want the callback to be sent to the card.
If a handler was called from a group then I might want the callback to be
sent to the group.
The current solution is to pass the long id of the object you want the
callback sent to as a parameter to the library handlers. For example:
restAPIGetObjects tId, the long id of me # callback will sent to me
If you aren't using password protected stacks then you can use `the
executioncontexts` to get the information you need to determine the caller.
But when a stack is password protected the necessary information isn't
included in `the executioncontexts`.
I have a recent real world example. I rewrote the REST API interface in an
application I work on to use behaviors that I attach to cards in my UI
stacks. The design allows me to segment REST calls made within a specific
object (card or group) so that callbacks and cleanup are very simple to
manage. The need to pass the long id of the caller as a parameter if I want
the callback for a specific handler to be sent to a group on the card
shouldn't be part of a handlers parameter list, however.
More information about the use-livecode