Globals and clone this stack

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

Globals and clone this stack

Post by Mag »

Hi all!

If I clone a stack the new instance of the stack uses the same globals, right? And if I would like to have different globals in each instance of the stack? :oops: :oops: :roll:
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Globals and clone this stack

Post by Klaus »

Hi Mag,

globals are... well, globals! No way! :D

Maybe you can "get away" with LOCAL vars in the stack script?


Best

Klaus
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld »

If you need values specific to the stack you could use custom properties, effectively binding the data to the object.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Globals and clone this stack

Post by Mag »

Thank you Klaus, I will examine the possibility to implement local vars...

FourthWorld nice idea, are the custom propperties a lot slower than globals?
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld »

Mag wrote:FourthWorld nice idea, are the custom propperties a lot slower than globals?
Measurably, but rarely noticeably.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Globals and clone this stack

Post by Mag »

Thank you for the info guys!

And if I have two instances of the same main stack (called for example "MyStack"), each one with their substacks, when I set a custom property for the stack MyStack from within a substack, can I be sure that the property set is the one of the current mainstack?

PS
I know, not an easy question... 8)
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Globals and clone this stack

Post by Mag »

PS
I noticed that the substacks are not cloned with the main stack. So if I have to set a custom property of a main stack cloned from a substack, I have to know the name of it. This because the substacks continues to own by the original stack.
FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10103
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld »

After executing a "create" or "clone" command, the value on the local variable"it" will contain a absolute reference to the new object.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Mag
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 802
Joined: Fri Nov 16, 2012 10:51 pm

Re: Globals and clone this stack

Post by Mag »

Thank you Richard!
Post Reply