Saving Stacks

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Saving Stacks

Post by Danny » Sat Feb 19, 2011 11:55 pm

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

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Saving Stacks

Post by dburdan » Sun Feb 20, 2011 12:53 am

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,

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Saving Stacks

Post by Danny » Sun Feb 20, 2011 2:38 am

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: Saving Stacks

Post by BvG » Sun Feb 20, 2011 12:42 pm

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.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Saving Stacks

Post by Danny » Mon Feb 21, 2011 6:15 pm

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
Attachments
Example Program 1.livecode.zip
(1.9 KiB) Downloaded 282 times

dburdan
Posts: 104
Joined: Fri Jan 28, 2011 5:39 am
Location: California, USA

Re: Saving Stacks

Post by dburdan » Mon Feb 21, 2011 7:47 pm

Hey Danny,
Go to File>Standalone Project Settings>iOs> Then uncheck Exits On Suspend.

This will save exactly where you were.

Danny
Posts: 106
Joined: Tue Nov 09, 2010 1:28 am

Re: Saving Stacks

Post by Danny » Mon Feb 21, 2011 8:26 pm

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

Post Reply

Return to “iOS Deployment”