Page 1 of 1

Cloned stacks seem to share globals & events

Posted: Mon Jan 29, 2018 4:43 pm
by tetsuo29
Hello,

I've been building a simple count down timer app. Once I got it working like I want, I thought it would be nice to be able to have multiple timers so I added a "File, New" menu and in that handler, put the following code:

Code: Select all

case "New"
    clone stack "Count It Down"
    break
So far, so good. After I build my standalone, I can create new timer instances but, unfortunately, they seem to share global variables and events fired in one stack affects the others. Is there a way to clone a stack and have each stack not share globals or events?

Re: Cloned stacks seem to share globals & events

Posted: Mon Jan 29, 2018 6:21 pm
by tetsuo29
Sorry folks. I should have thought more before posting.

It's just my global variable that I was using as a semaphore that was being shared by all instances of the cloned stacks.

I made it a script local variable instead of a global and now everything is working like it should.

Re: Cloned stacks seem to share globals & events

Posted: Mon Jan 29, 2018 8:38 pm
by dunbarx
Hi.

Yep, that is how globals roll.

You might include a filter that checks the identity of the topStack, assuming some property in each clone is different, but that may not be as robust as using script locals.

Craig Newman