Check if substack is already loaded

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
bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Check if substack is already loaded

Post by bergsy » Thu Apr 16, 2015 3:14 am

Hi,

I want to be able to check to see if a substack has already been loaded on screen so I don't reinitialise the objects. I want code something like that below from my main stack:

-- need code here to figure out if stkStack2 is already showing to the user
if bVisible then
go stack stkStack2
else
put "test" into fld fldTest of stack stkStack2
go stack stkStack2
end if

I have tried looking at the visible property of the stack stkStack2, but that is always true, whether it has been loaded on the screen or not

Any suggestions appreciated

Cheers

bergsy

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

Re: Check if substack is already loaded

Post by Simon » Thu Apr 16, 2015 4:02 am

Hi bergsy,
Check out "openStacks" in the dictionary.

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

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

Re: Check if substack is already loaded

Post by FourthWorld » Thu Apr 16, 2015 5:36 am

You could also set a flag in a global, something like gInited - check it during init and if empty run your setup and then set it to true.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bergsy
Posts: 45
Joined: Mon Oct 28, 2013 10:51 pm

Re: Check if substack is already loaded

Post by bergsy » Thu Apr 16, 2015 8:14 am

Hi Simon,

Works great - I just check for the stack name in all the open stacks

Cheers

Bergsy

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

Re: Check if substack is already loaded

Post by Klaus » Thu Apr 16, 2015 12:47 pm

Hi Bergsy,

little background info:
When you open a stack (file from disk), then this stack and ALL its substacks, if any, are loaded into RAM.
So your substack has in fact already been loaded and you wanted to check if is is OPEN already.


Best

Klaus

Post Reply