Who is "me" in this line?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
standgale
Posts: 26
Joined: Fri May 07, 2021 4:12 am

Who is "me" in this line?

Post by standgale » Fri Jan 28, 2022 4:27 am

I have the following line

Code: Select all

   put "" into field "tableDiscrep" of card "cardCalculate" of me
But it can't find the card.
So I was wondering - who is "me" here?

This line is in a stack-only script which is a behaviour of the main stack. The main stack has a card by this name.
This Livecode wiki page https://livecode.fandom.com/wiki/Me says
If me is executed in a behavior script, then me refers to the object that is executing the behavior script.
So I would have thought that the stack is "me" but it seems not. Is the behaviour "me"?

Oh yeah, this line is in a handler, which is called from another handler within the same script - but that handler is called from another script in another stack. In fact, it is being called from the behaviour script of cardCalculate, the card that can't be found.

It does seem to work if I specify the stack name rather than use "me", but I'd like to know who "me" is in here.

Thanks.

rkriesel
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 118
Joined: Thu Apr 13, 2006 6:25 pm

Re: Who is "me" in this line?

Post by rkriesel » Fri Jan 28, 2022 4:57 am

standgale wrote:
Fri Jan 28, 2022 4:27 am
... but I'd like to know who "me" is in here.
Hi, standgale.
You could insert code like this:

Code: Select all

answer the long name of me
-- Dick

stam
Posts: 2682
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: Who is "me" in this line?

Post by stam » Fri Jan 28, 2022 11:02 am

standgale wrote:
Fri Jan 28, 2022 4:27 am
This line is in a stack-only script which is a behaviour of the main stack. The main stack has a card by this name.
This Livecode wiki page https://livecode.fandom.com/wiki/Me says
If me is executed in a behavior script, then me refers to the object that is executing the behavior script.
So I would have thought that the stack is "me" but it seems not. Is the behaviour "me"?
You could replace “me” with “this stack” - that’s still abstracted so can be used with any stack. Not tested though, as am travelling abroad…

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Who is "me" in this line?

Post by Klaus » Fri Jan 28, 2022 11:35 am

Yes, ME is the stack that this behavior is attached to!

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Who is "me" in this line?

Post by SparkOut » Fri Jan 28, 2022 2:17 pm

Is it really?
I thought me referenced the specific object calling the script.
A behavior script runs "instanced" to resolve all references relative to the calling object as if it were the "longhand" script of that object.
So "me" could/should resolve to the card name in the substack I think. Is it trying to refer to a card "of a card" rather than a stack?

Klaus
Posts: 13828
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Who is "me" in this line?

Post by Klaus » Fri Jan 28, 2022 2:28 pm

Well, "... of cd xyz of me" really makes me think this is a stack, what else has cards? :D

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Who is "me" in this line?

Post by SparkOut » Fri Jan 28, 2022 2:32 pm

Yes but what happens if the script resolves "me" to "card xyx of stack xyz" and means the script tries to do something with field "abc" of card "abd" of card "xyx" of stack "xyz"?

Dick's suggestion to answer the long name of me within that script is a good one.

standgale
Posts: 26
Joined: Fri May 07, 2021 4:12 am

Re: Who is "me" in this line?

Post by standgale » Fri Feb 04, 2022 1:43 am

rkriesel wrote:
Fri Jan 28, 2022 4:57 am
You could insert code like this:

Code: Select all

answer the long name of me
-- Dick
thanks for that advice. Can't believe I forgot to do that simple thing!

I tried it and when I run the program in the IDE then "me" is my main stack like its supposed to be, but when I try to "save as a standalone application" it pops the message box as well, and "me" is now the behaviour script the code is physically located in.

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”