Page 1 of 1

Saving data in iPhone app (revMobile)

Posted: Fri Apr 02, 2010 10:56 pm
by ukaussie
How might i go about saving data before the app quits? and then loading the data again the next time the app opens?

Re: Saving data in iPhone app (revMobile)

Posted: Sat Apr 03, 2010 11:12 am
by Klaus
Hi ukaussie,

check the PDF that came with the latest alpha (6 or 7?) for the different "specialfolderpath()" codes supported on the iPhone.


Best

Klaus

Re: Saving data in iPhone app (revMobile)

Posted: Sat Apr 03, 2010 2:36 pm
by ukaussie
Hi Klaus,

I've read the PDF but it is not clear how to transform that information into actual code. I've tried setting the code to the below (for saving and retrieving, respectively), but it doesn't work.

Code: Select all

put tResultsField into URL "file:/home/documents/saveddata.txt"

Code: Select all

put URL "file:/home/documents/daveddata.txt" into field "resultsField"
Do i have the path correct? They recommend saving data to the 'documents' folder within the iPhone app bundle. If i have the path correct do i have the syntax incorrect?

Grant.

Re: Saving data in iPhone app (revMobile)

Posted: Sat Apr 03, 2010 2:54 pm
by Klaus
Hi Grant,

use the "specialfolderpath()" function!

...
## I would recommend to create a folder for your app in that folder first.
## This way ther is no danger that a file named "saveddata.txt" already exists!
put tResultsField into URL("file:" & specialfolderpath("documents") & "/saveddata.txt")
...

Best

Klaus

Re: Saving data in iPhone app (revMobile)

Posted: Sat Apr 03, 2010 5:44 pm
by ukaussie
Hi Klaus,

That worked! Brilliant, thanks for your help.

Cheers,

Grant.

Re: Saving data in iPhone app (revMobile)

Posted: Sat Apr 10, 2010 9:01 pm
by fmuller
Hello,

I wrote these 2 functions below for my application :
And interesting link for folders : http://intkeystrokes.posterous.com/wher ... obile-runr

Code: Select all

global gConfigArray

function fSaveConfigFile
   --Save Configuration File
   put specialFolderPath (documents) & "/Config.txt" into lConfigFile
   open file lConfigFile for write
   repeat with tVarNum = 1 to 11
      write gConfigArray[tVarNum] & CR to file lConfigFile 
   end repeat
   close file lConfigFile
end fSaveConfigFile

function fReadConfigFile
   --Read Configuration File
   put specialFolderPath (documents) & "/Config.txt" into lConfigFile
   open file lConfigFile for read
   repeat with tVarNum = 1 to 11
      read from file lConfigFile for 1 line
      put it into gConfigArray[tVarNum]
   end repeat
   close file lConfigFile
end fReadConfigFile
I hope this help, Cheers, Fabrice