Page 1 of 2
Saving Contents of Entire Stack (Window)
Posted: Tue Feb 15, 2011 4:23 pm
by townsend
I was reading Sarah Reichelt's article,
Saving data in LiveCode Standalones
(Search for: "tutorials/saving_data_in_revolution")
By far the easiest method is to make sure that you can save all the sub-stacks in your project. This is frequently called the splash screen method because the best way to do it is to have the mainStack of your application be nothing more than a decorative splash screen which takes you to the sub stacks where all the action occurs and where any data changes can be saved as part of the stack.
Does this mean that if I take the time to populate a Grid from a remote data source, and exit the program, when the program starts again, the Grid will remain populated?? It sounds that way.
Wow-- in any other development environment, this would require two additional routines: one to remove the data from the Grid and save it to disk file, and then another to read that file and re-populate the grid.
Re: Saving Contents of Entire Stack (Window)
Posted: Tue Feb 15, 2011 8:21 pm
by dunbarx
What Sarah means is that the throw-away splash screen is the actual executable for the file. Make that your startup (and it can have any sort of initialization stuff you might need), and then get down to the working part of your application, which is one or many other stacks.
I just always do it that way. I never worry about saving, because all the substacks will be fine. I usually hide the expendable, but utterly necessary splash screen.
Craig Newman
Re: Saving Contents of Entire Stack (Window)
Posted: Tue Feb 15, 2011 8:42 pm
by townsend
Thanks for your reply. Yes-- but if If I use the Splash Screen format...
Does this mean that if I take the time to populate a Grid from a remote data source, and exit the program, when the program starts again, the Grid will remain populated??
Re: Saving Contents of Entire Stack (Window)
Posted: Tue Feb 15, 2011 10:59 pm
by townsend
To be honest, I'm still confused about sub-stacks.
...which takes you to the sub stacks where all the action occurs and where any data changes can be saved as part of the stack.
This may be refering to-- just saving your latest work-- and not the data in your controls.
Sarah also talks about how the different sub-stacks are saved, physically, on windows and mac machines. It sounds like breaking you project into lots of stacks, creates lots files, instead of having everything being contained in one large exe.
This may make it easier to do remote updates. But only if sub-stack files are not locked by the controlling splash exe.
None the less,
I'm still wondering, is there some simple way to save the data in a Grid,
without having to write separate Save and Load routines, for each Grid in my Stack.
Re: Saving Contents of Entire Stack (Window)
Posted: Tue Feb 15, 2011 11:56 pm
by dunbarx
A datagrid is merely a special group of ordinary LC controls. The contents will be saved.
Try it. Make a simple splash screen stack with a substack containing a dg. In the opencard handler of the splash, open the substack. Populate the dg. Make sure you save the stacks upon quitting. Make a standalone. Play with the dg. Quit. Open again. See the changes. Should be a snap.
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 12:46 am
by townsend
In the opencard handler of the splash, open the substack...
Sorry, I can't seem to find the "opencard handler" of the main stack.
There are two possibilities.
1- Clicking on the main stack first, from the menu bar, I select Object, and Stack Inspector.
Then in the Inspector box, I see many properties. I haven't found it in there.
2- Also, I right click on the main stack and select, Edit Stack Script.
There-- I see reference to Handlers, but they're all blank.
Thanks for you help on this DunBarx.
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 12:54 am
by jharris
I am new here (and loving every minute of it)... but I believe you have to start the handler yourself. It is the only way I have found to to it.
Right click on stack and select "Edit Stack Script" then type in your handler.
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 1:39 am
by townsend
Yes! That worked!
Code: Select all
on openCard
open subStack
end openCard
And... In fact, all the data in the SubStack window was saved!
This is pretty amazing. This is going to save me a LOT of time.
This-- is something Visual Studio, AlphaFive, Morfik, & Real Studio couldn't do.
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 3:53 am
by dunbarx
Um, er, hi.
I had no idea you were really at the very beginning.
All objects in LC, like buttons, fields, cards and stacks can have scripts attached to them. You have just been told that you create these as needed. Good.
It is possible to have a useful stack that contains no scripts. It is not likely that you will be satisfied with such a thing for long.
It is now critical that you understand just a few more concepts. Please read about commands, functions and properties. You absolutely MUST create a few simple stacks and write some scripts. Make an address book, a calculator, or anything. It will not matter how basic or simple your stack is, because very soon you will be immersed in adding features and functionality, and this will cause you far greater grief, and triumph, than the stack warrants. The final product will be irrelevant, and likely useless. The exercise will be priceless, and fun.
An address book then. Get going. Post often with questions and problems. The community here races to see who can answer first, and show off how clever we are. Good luck.
Craig Newman
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 5:39 am
by jharris
You absolutely MUST create a few simple stacks and write some scripts.
I am a new LiveCode user also. I have been working on a simple sqlite database app to store information. Not worth anything, but I am learning a lot from it. Doing a simple app has also helped me with learning to reference the documentation.
This-- is something Visual Studio, AlphaFive, Morfik, & Real Studio couldn't do.
I use Visual Studio at my 40 hour a week job and most of the time for contract work I do on the side. I have been using RealStudio for the past year, trying to come up with a cross-platform database app. I never could come up with a finished app that worked well on Windows OS. After using LiveCode for a couple of weeks I think I have found the tool I want to stick with for cross-platform work. I am really amazed at what you can do with it. I have tried it several times over the years, but never cared much for the language. This time I purchased a license and decided I would take the time to learn it. Right now I am really impressed with LiveCode.
JHarris
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 11:50 am
by Klaus
Hi JHarris,
check these great resources here and spread the word
http://www.runrev.com/developers/lesson ... nferences/
Best
Klaus
Re: Saving Contents of Entire Stack (Window)
Posted: Wed Feb 16, 2011 1:26 pm
by jharris
Hi Klaus,
That link has some good information for beginners. That will give me something to read on my lunch hour today. I am only getting a few minutes a day to work with LiveCode, but I am reading every chance I get.
Thanks for the link.
JHarris
Re: Saving Contents of Entire Stack (Window)
Posted: Thu Feb 17, 2011 11:06 pm
by townsend
Thanks everyone for your help of this but... my tests tell me,
grid data is only saved in the development environment due to the "live" nature of LiveCode.
Once the application is compiled into an executable, the state of the stack
or sub-stack is not saved, unless the grid data is specifically written out to disk.
Am I right? On the upside, I see it is possible to save all grid data out to a text file with one line of code.
Code: Select all
Send "PrintKeys" to group "DataGrid1"
But to load the same data back into the grid-- that text file will need to be read one line and a time and parsed back into each cell.
Is it possible that any of the Grid plugins offer a Save and Load feature?
Re: Saving Contents of Entire Stack (Window)
Posted: Fri Feb 18, 2011 12:48 am
by doc
Hello townsend,
I think you are trying to make it harder than it needs to be...
...have a look at the details for "save" in the dictionary.
It's been my experience that coming from just about any other language makes you want to over-engineer whatever your task may be, when LiveCode very often offers an extremely simple solution.
Regards,
-Doc-
Re: Saving Contents of Entire Stack (Window)
Posted: Fri Feb 18, 2011 4:57 pm
by pmc
this method doesn't work in standalone if substacks needs to be edit and saving the changes. I have headache right until now on how to save changes in standalone app.