Page 1 of 1
Losing text in iPad simulator
Posted: Thu Jun 30, 2011 7:07 pm
by alfredomorai
Hi
I need your help, please...
In a stack I have one card field with the top ten players of a game, and the content of the card field updates If it is necessary. All works fine, but...
In the iPad simulator the card field updates too, when I quit the app (pressing the home button) and back to game, the card field does not show the updates. What can I do?
Thank you very much and greetings from Mexico
Alfredo Mora Izaguirre
Re: Losing text in iPad simulator
Posted: Thu Jun 30, 2011 7:37 pm
by Klaus
Hola Alfredo,
this is correct behaviour!
Standalones never save themselves, so you need to take care of this.
Do this:
1. When your app starts you need to check if you already wrote the content of your field to a file before.
2. If yes, read that file and put its content back into that field.
3. When the stack closes, write the content of your field to that file.
You can use specialfolderpath("documents") where your app has write permission:
Code: Select all
on preopenstack
## do your preopenstack stuff here...
## "Build" the absolute path to your file:
put specialfolderpath("documents") & "/" & "your filename here.txt") into myPrefs
## Don't try to access a non-existing file! ;-)
if there is a file myPrefs then
put url("file:" & myPrefs) into fld "your top players fieldname here" of cd 1 ## or whereever that field lives
end if
end preopenstack
## Write fields content to file:
on closestack
put specialfolderpath("documents") & "/" & "your filename here.txt") into myPrefs
put ld "your top players fieldname here" of cd 1 into url("file:" & myPrefs)
end closestack
Of course you can use another name for the file
Best from germany
Klaus
Re: Losing text in iPad simulator
Posted: Fri Jul 01, 2011 4:13 am
by alfredomorai
Klaus,
Thank you very much, now all works fine!
Greetings from Mexico,
Alfredo Mora Izaguirre