Test for If Sub-Stack is Open

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
townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Test for If Sub-Stack is Open

Post by townsend » Mon Jun 25, 2012 10:18 pm

It's convenient that you can manipulate the objects of sub-stacks even when they are closed.
So I've got a Timer which keeps on firing, even after the Sub-Stack is closed.
Is there some way to test whether or not a stack is open or closed?

If not-- I could just use a global variable. Just curious.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: Test for If Sub-Stack is Open

Post by dunbarx » Mon Jun 25, 2012 10:44 pm

Hi.

I played around just a little, probably you did too.

The "stacks" only returns open stacks, and the "substacks" is more a property of a mainstack. But if your stack is not in "the stacks", it is not open. You could check this.

But I think you want to know if a stack (one with its "destroyStack" set to "false") is still in memory, even though closed, right?

No clue. But I bet there is a native property that does this. LC has everything else.

Craig

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Test for If Sub-Stack is Open

Post by sturgis » Tue Jun 26, 2012 1:04 am

I think what you're looking for is revloadedstacks


edited: Will show stacks, loaded into memory or visible and open.

townsend
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 430
Joined: Sun Feb 13, 2011 8:43 pm

Re: Test for If Sub-Stack is Open

Post by townsend » Tue Jun 26, 2012 3:47 pm

Thanks for your feedback on this.

I used:

Code: Select all

set the destroyStack of stack "mySubStack" to true
close stack "mySubStack" 
Then, it turns out, the revloadedstacks() function shows:
All stacks part of the main stack. In memory or not. Open or not.

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

Re: Test for If Sub-Stack is Open

Post by Klaus » Tue Jun 26, 2012 3:55 pm

Hi guys,

hint: I think "revlodadedstacks()" and other "revXXX" commands/functions are only available in the IDE and not in runtimes!


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Test for If Sub-Stack is Open

Post by sturgis » Tue Jun 26, 2012 4:33 pm

Note: When included in a standalone application, the Common library is implemented as a hidden group and made available when the group receives its first openBackground message. During the first part of the application's startup process, before this message is sent, the revLoadedStacks function is not yet available. This may affect attempts to use this function in startup, preOpenStack, openStack, or preOpenCard handlers in the main stack. Once the application has finished starting up, the library is available and the revLoadedStacks function can be used in any handler.
Don't see anything contra-indicating use of this in a standalone, and the above paragraph seems to indicate it will work fine, but since I haven't tested it in a standalone your mileage may vary. Documentation and reality don't always mesh!

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

Re: Test for If Sub-Stack is Open

Post by Klaus » Tue Jun 26, 2012 4:41 pm

Hi all,

oops, sorry, looks like I am not up-to-date 8)


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Test for If Sub-Stack is Open

Post by sturgis » Tue Jun 26, 2012 4:46 pm

If your stack app has the mainstack and all other stacks you use saved as substacks of the mainstack, then yes. You open the mainstack, viola' the main and substacks are shown in the app browser. (meaning the substacks are in memory) If you right click the substack in the app browser one of the options is to close it and remove it from memory.

If you have a main stack and load external stacks using code the stacks won't show up in the app browser and are not in memory (assuming they haven't been previously loaded) at which point it only shows "in memory" stacks.

As mentioned the destroystack property can change whether recently closed stacks are in memory or not.

At least I think this is how all this meshes together.
townsend wrote:Thanks for your feedback on this.

I used:

Code: Select all

set the destroyStack of stack "mySubStack" to true
close stack "mySubStack" 
Then, it turns out, the revloadedstacks() function shows:
All stacks part of the main stack. In memory or not. Open or not.

Post Reply