Un-opened Sub-Stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Un-opened Sub-Stack

Post by lohill » Sun Feb 02, 2014 1:27 am

Is it true that objects on cards of not yet opened sub-stacks are not accessible until that sub-stack has first been opened? Once that sub-stack has been opened it can then be closed and the objects will remain accessible. Specifically I want to have some datagrids on a substack and yet be able to access data from them at all times. How is the best way to handle that access without the user being aware.

Thanks,
Larry

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

Re: Un-opened Sub-Stack

Post by dunbarx » Sun Feb 02, 2014 6:10 am

Hi.

The substack is available from the mainstack even if it has not been navigated to. Make a new stack named "xxxx". Put a button in it. Make a substack named "zzzz". Put a field in it with some data. Go back to the main stack and put this in the button script:

Code: Select all

on mouseUp
 answer fld 1 of stack "zzzz"
end mouseUp
Save the stacks. Quit LC. Open the mainstack again and click the button.

Craig Newman

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

Re: Un-opened Sub-Stack

Post by Klaus » Sun Feb 02, 2014 1:54 pm

Hi Larry,

for completeness, you can even access stack files that are not open at all currently! :D
...
put specialfolderpath("documents") & "/a_stack.rev" into tStackFile
put the text of fld 1 of cd 2 of stack tStackFile into tText
...

tStackFile will point the engine to the MAINSTACK of that stack file, but can also access its substacks:
...
put the text of fld 1 of cd 2 of stack "a substack" of stack tStackFile into tText
...

Best

Klaus

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Un-opened Sub-Stack

Post by lohill » Mon Feb 03, 2014 6:08 pm

Thanks Craig and Klaus,
Wow. That is amazing.

Larry

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Un-opened Sub-Stack

Post by lohill » Wed Feb 05, 2014 8:16 pm

Craig,

What you said might be true in the simple case you give of one main stack and 1 substack but it absolutely does not work in my case with one main stack and about 20 substacks. If I quit the IDE and then come back in and open the main stack my routines for finding the the data which are contained on a card of the substack do not work until I first open the card in the substack. I can then close the card and everything works OK from that point. It may be that it is because the data I want are in dataGrids. My 'dispatch "FindIndex" to group "DataGrid 1" of card 1 of stack "Translations"' fails to bring back the index. My LineCode is the latest stable version - 6.5.2.

Now I need to ask what is the best way to open and close a card on a substack without the user being aware of it? I assume it would be at the open of my program.

Thanks

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

Re: Un-opened Sub-Stack

Post by dunbarx » Wed Feb 05, 2014 9:50 pm

Hmmm.

So I made a stack with a half dozen substacks. Put a field with some data on all substacks. Put a button on the mainstack asking for the data on those substacks. Saved. Quit LC. Reopened the mainstack from the finder. Clicked on the button. No problem.

I cannot believe, though have not tested, that the number of substacks (my 6 vs. your 20) matters. Can you do what I did?

Craig

EDIT. My fields are on card 1 of my substacks. This is the default target card when referencing the stack, since there is only one. Is it possible that you are trying to retrieve data from other cards than the first on your substacks? Because that would do it.

MORE EDIT. I see you explicitly reference the card. I will check a datagrid retrieval. Also, you can always lock the screen on preOpenWhatever, navigate to the substacks, and return.

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

Re: Un-opened Sub-Stack

Post by dunbarx » Wed Feb 05, 2014 10:09 pm

OK.

Tried it with a DG on one of the substacks. No problem:

Code: Select all

on mouseUp
   answer the dgtext of  group 1 of stack  "u7"
end mouseUp
Craig

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

Re: Un-opened Sub-Stack

Post by dunbarx » Wed Feb 05, 2014 10:31 pm

Also it makes no difference if the DG is on another card than the first one. Again, from the finder:

Code: Select all

on mouseUp
   answer the dgtext of  group 1 of cd 2 of stack  "u7"
end mouseUp
Comes back fine.

Craig

Post Reply