Saving Stacks
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Saving Stacks
So this will be my last question for a while but how do you save a stack? In my game I have some fields that change numbers but when I quit out of the app on my iPod Touch and open it again it resets it to what the saved stack is. So if I have the number 2 saved in one field then I play the game and makes it a 3. When I quit out of it then open it again it shows the field as number 2.
I have tried the "save" command but it didn't work.
Thanks,
Danny
I have tried the "save" command but it didn't work.
Thanks,
Danny
Re: Saving Stacks
Here you go.
Write:
put (DATA_HERE into URL("file:" & specialFolderPath("LOCATION_HERE") & "FILENAME")
Read:
put URL("file:" & specialFolderPath("LOCATION_HERE") & "FILENAME") into VARIABLE_HERE
This is what you would substitute for the LOCATION_HERE text I put.
• home – the (unique) folder containing the application bundle and its associated data and
folders
• documents – the folder in which the application should store any document data (this folder
is backed up by iTunes on sync)
• cache – the folder in which the application should store any transient data that needs to be
preserved between launches (this folder is not backed up by iTunes on sync)
• temporary – the folder in which the application should store any temporary data that is not
needed between launches (this folder is not backed up by iTunes on sync)
• engine – the folder containing the built standalone engine (i.e. the bundle). This is useful for
constructing paths to resources that have been copied into the bundle at build time.
In general you should only create files within the documents, cache, and temporary folders. Indeed,
Write:
put (DATA_HERE into URL("file:" & specialFolderPath("LOCATION_HERE") & "FILENAME")
Read:
put URL("file:" & specialFolderPath("LOCATION_HERE") & "FILENAME") into VARIABLE_HERE
This is what you would substitute for the LOCATION_HERE text I put.
• home – the (unique) folder containing the application bundle and its associated data and
folders
• documents – the folder in which the application should store any document data (this folder
is backed up by iTunes on sync)
• cache – the folder in which the application should store any transient data that needs to be
preserved between launches (this folder is not backed up by iTunes on sync)
• temporary – the folder in which the application should store any temporary data that is not
needed between launches (this folder is not backed up by iTunes on sync)
• engine – the folder containing the built standalone engine (i.e. the bundle). This is useful for
constructing paths to resources that have been copied into the bundle at build time.
In general you should only create files within the documents, cache, and temporary folders. Indeed,
Re: Saving Stacks
I don't mean to be dumb but I might need some more description. But I have some general questions. Is this server based? I don't think it looks like that but I see some storage words. And do I need a URL to something?
Home: Would this be in quotes ""? and do I just put the file name there?
Documents: What Documents Folder? On my computer?
Cache, temporary and engine: I don't know what folders to put in.
I'm just trying to save fields but if this is the way I have to go then I have no problem with it.
Thanks,
Danny
Home: Would this be in quotes ""? and do I just put the file name there?
Documents: What Documents Folder? On my computer?
Cache, temporary and engine: I don't know what folders to put in.
I'm just trying to save fields but if this is the way I have to go then I have no problem with it.
Thanks,
Danny
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Re: Saving Stacks
iOS highly regulates where you can save what. that Is why you need to use specialFolderPath to find the places where you're allowed to save by iOS. Read the specialFolderPath function entry of the dictionary.
Note that URL can be used with different things then just "http:" for example "file:" for text files or "binfile:" for binary data. read the URL keyword entry in the dictionary.
You can save a whole stack, instead of just a text file, but that needs some special handling when you start up your app, otherwise your app would always use the stacks that are contained in the standalone, and those can't be saved. If you want to save a stack, you might want to investigate the so called splash stack approach, here is a lesson about that.
And here is a lesson about saving stuff on iOS.
Note that URL can be used with different things then just "http:" for example "file:" for text files or "binfile:" for binary data. read the URL keyword entry in the dictionary.
You can save a whole stack, instead of just a text file, but that needs some special handling when you start up your app, otherwise your app would always use the stacks that are contained in the standalone, and those can't be saved. If you want to save a stack, you might want to investigate the so called splash stack approach, here is a lesson about that.
And here is a lesson about saving stuff on iOS.
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
Re: Saving Stacks
Hey BvG,
I've been trying to get my app to save where it was at and it's not going well. I posted a file with a sample program of what i'm trying to do and what I want to do. I have an explanation in the program. Would you mind taking a look at it?
Thanks,
Danny
I've been trying to get my app to save where it was at and it's not going well. I posted a file with a sample program of what i'm trying to do and what I want to do. I have an explanation in the program. Would you mind taking a look at it?
Thanks,
Danny
- Attachments
-
- Example Program 1.livecode.zip
- (1.9 KiB) Downloaded 282 times
Re: Saving Stacks
Hey Danny,
Go to File>Standalone Project Settings>iOs> Then uncheck Exits On Suspend.
This will save exactly where you were.
Go to File>Standalone Project Settings>iOs> Then uncheck Exits On Suspend.
This will save exactly where you were.
Re: Saving Stacks
mmmm. Strange. When I turned off Exits On Suspend, it didn't work. Then I tried turning File Sharing "On" and I got a little bit of multitasking and thanks to that it was showing that it was saved. But when I closed out (and closed out of multitasking) it was back to the same saved stack and not what the numbers changed to.
Danny
Danny