stand alone saving
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
stand alone saving
This is my first project and I’ve learned a lot but am stuck on this one. I'm really glad this forum is available. Hope someone can help.
I need my application, converted to a stand-alone, to save content changes in fields on quitting. When run in the Player, content changes ARE saved. But in the stand-alone content in the fields reverts to the original content. Here’s the save script I’m using:
on menuPick pWhich
switch pWhich
case "Quit"
answer "Save changes?" with "Cancel" or "Don't Save" or "Save"
if it is "Cancel" then exit to top
if it is "Save" then
save this stack
close this stack
end if
break
end switch
end menuPick
I’ve also tried “save this cardâ€
I need my application, converted to a stand-alone, to save content changes in fields on quitting. When run in the Player, content changes ARE saved. But in the stand-alone content in the fields reverts to the original content. Here’s the save script I’m using:
on menuPick pWhich
switch pWhich
case "Quit"
answer "Save changes?" with "Cancel" or "Don't Save" or "Save"
if it is "Cancel" then exit to top
if it is "Save" then
save this stack
close this stack
end if
break
end switch
end menuPick
I’ve also tried “save this cardâ€
-
- Posts: 13
- Joined: Fri Oct 05, 2007 12:45 am
Re: stand alone saving
[quote="watsonjk"]This is my first project and I’ve learned a lot but am stuck on this one. I'm really glad this forum is available. Hope someone can help.
I need my application, converted to a stand-alone, to save content changes in fields on quitting. When run in the Player, content changes ARE saved. But in the stand-alone content in the fields reverts to the original content. Here’s the save script I’m using:
on menuPick pWhich
switch pWhich
case "Quit"
answer "Save changes?" with "Cancel" or "Don't Save" or "Save"
if it is "Cancel" then exit to top
if it is "Save" then
save this stack
close this stack
end if
break
end switch
end menuPick
I’ve also tried “save this cardâ€
I need my application, converted to a stand-alone, to save content changes in fields on quitting. When run in the Player, content changes ARE saved. But in the stand-alone content in the fields reverts to the original content. Here’s the save script I’m using:
on menuPick pWhich
switch pWhich
case "Quit"
answer "Save changes?" with "Cancel" or "Don't Save" or "Save"
if it is "Cancel" then exit to top
if it is "Save" then
save this stack
close this stack
end if
break
end switch
end menuPick
I’ve also tried “save this cardâ€
-
- Posts: 179
- Joined: Sat Apr 08, 2006 11:08 pm
- Contact:
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Rather than a substack, you'd probably want the window to be saved in a completely separate stack file.
For lots of great info on saving data from standalones, see this great article from Sarah Reichelt at revJournal.com:
http://www.revjournal.com/tutorials/sav ... ution.html
For lots of great info on saving data from standalones, see this great article from Sarah Reichelt at revJournal.com:
http://www.revjournal.com/tutorials/sav ... ution.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Thanks for the help. I think using substacks for saving is going to work. A faulty assumtion that was leading me astray was that saving the mainstack would also save the substacks (I have 5 of them). So I guess that I'll need to have the user save each substack as they leave it - is that correct?
Much appreciation for unsticking me.
Jim
Much appreciation for unsticking me.
Jim
watsonjk,
You only need to save the stack file. If a stack file contains 1 main stack and 5 substacks, you can save the main stack, which will automatically save the 5 substacks as well.
You can't save a stack if it is part of a standalone. You might want to make an almost empty standalone, which does nothing but searching for a stack in the same directory and opening it. This way, you can save all changes in your stack, because it is not part of the standalone, while you can have just one stack file with the main stack and its 5 substacks. This should also allow you to run your original code.
Best,
Mark
You only need to save the stack file. If a stack file contains 1 main stack and 5 substacks, you can save the main stack, which will automatically save the 5 substacks as well.
You can't save a stack if it is part of a standalone. You might want to make an almost empty standalone, which does nothing but searching for a stack in the same directory and opening it. This way, you can save all changes in your stack, because it is not part of the standalone, while you can have just one stack file with the main stack and its 5 substacks. This should also allow you to run your original code.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Thanks Mark.
I must have built my stacks in some strange way because when I tried saving the main stack (a splash page), it wouldn't save changes to the substacks.
Hopefully I'm not working myself into a mess but when I tried I putting save options in the menubars of each of the substacks, it did work. It's a little clunky to save each time I move to another page but in this particular app most of the action is on individual pages.
I wonder if the fact that I added the menubar after the stacks were made might have made a difference. I'm going to try building a new set of stacks and substacks with the menus in place from the start to see if that makes it so the substacks save when saving the main stack. Possible?
Thanks again.
Jim
I must have built my stacks in some strange way because when I tried saving the main stack (a splash page), it wouldn't save changes to the substacks.
Hopefully I'm not working myself into a mess but when I tried I putting save options in the menubars of each of the substacks, it did work. It's a little clunky to save each time I move to another page but in this particular app most of the action is on individual pages.
I wonder if the fact that I added the menubar after the stacks were made might have made a difference. I'm going to try building a new set of stacks and substacks with the menus in place from the start to see if that makes it so the substacks save when saving the main stack. Possible?
Thanks again.
Jim
Hi Jim,
Are you sure that you have substacks? If the stacks are not saved, I suspect they are main stacks themselves or the cantModify property of the substacks is true.
A mainstack and its substacks contains of only one file. How many files do you have?
If you save a main stack as a standalone, you can't save the substacks that are part of that main stack. You must make a new splash stack, which opens the single stack file containing the mainstack and the substacks of your project.
(Of course, a project can consist of multiple stacks files, but I don't think that's the case here).
Best,
Mark
Are you sure that you have substacks? If the stacks are not saved, I suspect they are main stacks themselves or the cantModify property of the substacks is true.
A mainstack and its substacks contains of only one file. How many files do you have?
If you save a main stack as a standalone, you can't save the substacks that are part of that main stack. You must make a new splash stack, which opens the single stack file containing the mainstack and the substacks of your project.
(Of course, a project can consist of multiple stacks files, but I don't think that's the case here).
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Hi Mark,
It is great that you are willing to walk me through this. I'd really like to understand how the file structure works and how it looks when in stand alone. I hope you don't mind if I need help with your suggestions/questions:
[quote="Mark"]Hi Jim,
Are you sure that you have substacks? - I think so. In the application browser, it shows them as indented below the main stack.
If the stacks are not saved, I suspect they are main stacks themselves or the cantModify property of the substacks is true. - Can't modify is unchecked.
A mainstack and its substacks contains of only one file. How many files do you have? - When I open my project, I go to "Open Recent File", click on the name of the mainstack and it opens it and the application browser has all of the substacks available so I'm guessing it means I only have one file - there is only one icon for it.
If you save a main stack as a standalone, you can't save the substacks that are part of that main stack. You must make a new splash stack, which opens the single stack file containing the mainstack and the substacks of your project. (Of course, a project can consist of multiple stacks files, but I don't think that's the case here). - Since I can save what I think are the substacks, maybe that means I do have multiple stacks. How can I tell?
Thanks again.
Jim
It is great that you are willing to walk me through this. I'd really like to understand how the file structure works and how it looks when in stand alone. I hope you don't mind if I need help with your suggestions/questions:
[quote="Mark"]Hi Jim,
Are you sure that you have substacks? - I think so. In the application browser, it shows them as indented below the main stack.
If the stacks are not saved, I suspect they are main stacks themselves or the cantModify property of the substacks is true. - Can't modify is unchecked.
A mainstack and its substacks contains of only one file. How many files do you have? - When I open my project, I go to "Open Recent File", click on the name of the mainstack and it opens it and the application browser has all of the substacks available so I'm guessing it means I only have one file - there is only one icon for it.
If you save a main stack as a standalone, you can't save the substacks that are part of that main stack. You must make a new splash stack, which opens the single stack file containing the mainstack and the substacks of your project. (Of course, a project can consist of multiple stacks files, but I don't think that's the case here). - Since I can save what I think are the substacks, maybe that means I do have multiple stacks. How can I tell?
Thanks again.
Jim
This is a distinction that confused me at the beginning too. Mostly this came from the fact, that in rev-terms, two (or three) things are called stack.
There is the stack file, basically a document in your Explorer respectively Finder. A stack file can have multiple logical parts (fancy speak for "there's hidden stuff within"). these parts are the stacks (you can think of them as windows) within the mentioned stack file. A stack file can have multiple substacks, or none at all. However it always has exactly one mainstack.
When you make a standalone, the stack file will be copied to create an executable program. As programs can't be saved, you can't save the mainstack (or any of it's substacks) which made up the original stack file in your application.
Of course that's further confused by the ability to let rev export the substacks into files next to the executable when it creates the program. This actually takes all the substacks, and saves each of them into their own saveable file. Of course they're each their own mainstack now.
Additionally, there can be mainstacks with substacks that do not exist in any stack file, because they haven't been saved to the harddisk yet, and only exist in memory.
So to sum it up here a list about stacks:
There is the stack file, basically a document in your Explorer respectively Finder. A stack file can have multiple logical parts (fancy speak for "there's hidden stuff within"). these parts are the stacks (you can think of them as windows) within the mentioned stack file. A stack file can have multiple substacks, or none at all. However it always has exactly one mainstack.
When you make a standalone, the stack file will be copied to create an executable program. As programs can't be saved, you can't save the mainstack (or any of it's substacks) which made up the original stack file in your application.
Of course that's further confused by the ability to let rev export the substacks into files next to the executable when it creates the program. This actually takes all the substacks, and saves each of them into their own saveable file. Of course they're each their own mainstack now.
Additionally, there can be mainstacks with substacks that do not exist in any stack file, because they haven't been saved to the harddisk yet, and only exist in memory.
So to sum it up here a list about stacks:
- Stacks are files
- Stacks are part of files when they're called mainstacks and substacks
- Each stack file has exactly one mainstack
- A stack file can have many substacks
- A mainstack and it's substacks which are an executable can't be saved
- Mainstacks and substacks can also exist only in memory, without being within files or executables
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
- Posts: 137
- Joined: Thu Jul 24, 2008 11:22 pm
Re: stand alone saving
Is there another way of doing this? I have basically set up a single card as a form which when completed is posted to a table field, so a very simple database if you please. I just want the data saved in that field. At some stage I will be expanding on this idea so will have multiple tables that I want to save. Should I put the tables i a sperate stack that opens up with the form and put save button on the form stack? will that do it or should I look to link to some kind of database?
Re: stand alone saving
Glenn,
You could have your form act as a splash screen, that is make a standalone from it. Then when it is started, it needs to open the table stack, which can be hidden. Then the table stack will save, since it is a separate main stack from the form, so won't be an executable. Another approach is to have the table stack save to a text file which is saved separately. It will then need to be read in each time the table stack is opened. It's faster than that sounds. One caution: when testing the latter approach, unless things have changed (I was away from Rev for quite some time). The text file will be written to the folder where the rev application is kept, not necessarily where your stacks are, if they in a separate documents folder.
Dave
You could have your form act as a splash screen, that is make a standalone from it. Then when it is started, it needs to open the table stack, which can be hidden. Then the table stack will save, since it is a separate main stack from the form, so won't be an executable. Another approach is to have the table stack save to a text file which is saved separately. It will then need to be read in each time the table stack is opened. It's faster than that sounds. One caution: when testing the latter approach, unless things have changed (I was away from Rev for quite some time). The text file will be written to the folder where the rev application is kept, not necessarily where your stacks are, if they in a separate documents folder.
Dave
Re: stand alone saving
Hi Glenn,
Just proceed as you're currently doing, but add a feature, which saves the data in an appropriate place, when the application closes. Just as with any other application, like TextEdit on Mac and NotePad on Windows for example, you can ask the user whether or not to save the changed data. Use the ask file command to ask the user where to save the file. This returns a value in the it variable, which you can use as your file path. Check the value in the result afterwards, to make sure that the file was written correctly. If it was written correctly, continue to quit the programme.
It is also possible to save the data automatically, if there is no need for multiple files. Just make sure that you keep your file in a writable place, such as the application data folder on Windows or the preferences folder on Mac.
You can even have your application start and read the file, when the user double-clicks that file and make everything much more user friendly. Feel free to ask about this when you have done the above.
Best regards,
Mark
Just proceed as you're currently doing, but add a feature, which saves the data in an appropriate place, when the application closes. Just as with any other application, like TextEdit on Mac and NotePad on Windows for example, you can ask the user whether or not to save the changed data. Use the ask file command to ask the user where to save the file. This returns a value in the it variable, which you can use as your file path. Check the value in the result afterwards, to make sure that the file was written correctly. If it was written correctly, continue to quit the programme.
It is also possible to save the data automatically, if there is no need for multiple files. Just make sure that you keep your file in a writable place, such as the application data folder on Windows or the preferences folder on Mac.
You can even have your application start and read the file, when the user double-clicks that file and make everything much more user friendly. Feel free to ask about this when you have done the above.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
- Posts: 137
- Joined: Thu Jul 24, 2008 11:22 pm
Re: stand alone saving
Thanks Mark. I'm up and running now. At some stage I'll look to link into a proper database. that'll be the next big challenge!