'send' and behaviors
Mark Schonewille
m.schonewille at economy-x-talk.com
Sat Jun 2 18:37:03 EDT 2012
Hi Graham,
A card is not a stack (obviously). The stack containing the card temporarily becomes the default stack, but "this stack" still refers to the currently visible card of the stack rather than the card containing the script. If you really want to refer to the card containing the script (or the behavior) then you need to use "me" (field x of me, the owner of me) instead of "this card".
--
Best regards,
Mark Schonewille
Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553
Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour spaces. http://www.color-converter.com
On 3 jun 2012, at 00:28, Graham Samuel wrote:
> It says in the LC docs for the 'send' command:
>
>> When the send command is used the stack containing the target handler temporarily becomes the defaultStack. All object references in the message are evaluated in the current context i. e. the defaultStack. Therefore references within the message that refer to "this card" or "this stack" will be referring to the card or stack where the target handler is located.
>
> I am relying on this: I have a line like this in a script on a particular card, say card "A" - in fact this line is in a behavior of the card:
>
> send "doSomething" to card "B"
>
> This works in the sense that the handler "soSomething" is executed, but if I include a line in the handler:
>
> put "This card is" && (the short name of this card)
>
> I get the name of the sending card (A), not the name of the target (B) - as a result the handler doesn't have its expected context and fails since references to (for example) fields on the card containing the handler script don't resolve properly. The handler is however also in a behavior, which has certainly been correctly associated with the target card.
>
> Am I doing something wrong, or is this an LC limitation, or is it a bug?
>
> Graham
More information about the use-livecode
mailing list