How references work in clone stacks

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
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

How references work in clone stacks

Post by Mag » Sat May 03, 2014 12:56 pm

Hi all,

If I understand correctly, when you clone a stack and then in that stack, you use a command with references to a card, this command refers to the card of the cloned stack, right?

For example,

Code: Select all

the field 1 of card 2 of this stack
always refers to the field 1 one of the card 1 of the cloned stack, and not to the original stack, is this right? :oops:

Klaus
Posts: 14205
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How references work in clone stacks

Post by Klaus » Sat May 03, 2014 1:09 pm

Hi Mag,

Hint:
don't use THE when addressing object in Livecode! 8)
Bad:
THE field 1 of card 2 of this stack

Good:
field 1 of card 2 of this stack

Well, it depends what the currently active "default" stack is, and WHEN and WHERE you fire this command.
Do you do this right after cloning the stack?

If in doubt, use the name of the cloned or target stack to be sure to address the correct stack!


Best

Klaus

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How references work in clone stacks

Post by Mag » Sat May 03, 2014 1:24 pm

Hi Klaus, thank you for the replay. The handler which refers to the object is already present in the cloned stack, so could be difficult to refer to the real stack name which is unknow at the time I wrote the handler. :roll:

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How references work in clone stacks

Post by Mag » Sat May 03, 2014 1:34 pm

I made a stack for testing, If someone is so kind to try it and sees possible problems, please posts here his doubts and advices.
Attachments
Clone i.livecode.zip
(1.03 KiB) Downloaded 157 times

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am

Re: How references work in clone stacks

Post by Simon » Sun May 04, 2014 12:37 am

Hi Mag,
I'm not clear on what you are asking in reference to the stack you posted?
It seems to be doing what it's supposed to? Logs are correctly posted to their fields.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: How references work in clone stacks

Post by Mag » Sat May 10, 2014 11:42 am

Hi Simon,

I made this stack to test if when a handler of an object tells "this stack" the target is the stack that own the object, regardless if the stack is the front most or not. Because I'm not sure if the test is constructed in the right way, I would be happy to hear other opinions and recommendations. Thank you for your feedback!

Post Reply