'send' and behaviors

Dar Scott dsc at swcp.com
Sat Jun 2 20:05:30 EDT 2012


This can be confusing.  I think it is the word "this" that causes confusion.  The behavior is strange in that "this stack", meaning the current stack, will change even when it is not foremost and even if it is invisible or deleted.  At times some folks naturally expect that and at times some other folks might expect otherwise before seeing how it works.  As you said, the important thing is to use 'me'.  We need a built-in object reference like 'the stack of me' or 'my stack'.  We can write our own "longIDOfStackOfMe()" function, I guess.

In addition the message path moves to the target object.  

Dar


On Jun 2, 2012, at 4:37 PM, Mark Schonewille wrote:

> 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
> 
> 
> _______________________________________________
> 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





More information about the Use-livecode mailing list