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 » Tue Apr 08, 2014 3:35 pm

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: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Globals and clone this stack

Post by Klaus » Tue Apr 08, 2014 4:00 pm

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: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld » Tue Apr 08, 2014 4:32 pm

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 » Tue Apr 08, 2014 7:56 pm

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: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld » Wed Apr 09, 2014 12:49 am

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 » Wed Apr 09, 2014 1:59 pm

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 » Wed Apr 09, 2014 2:37 pm

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: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Globals and clone this stack

Post by FourthWorld » Wed Apr 09, 2014 3:03 pm

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 » Wed Apr 09, 2014 3:29 pm

Thank you Richard!

Post Reply