Losing text in iPad simulator

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
alfredomorai
Posts: 2
Joined: Thu Jun 30, 2011 6:37 pm

Losing text in iPad simulator

Post by alfredomorai » Thu Jun 30, 2011 7:07 pm

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 :D

Alfredo Mora Izaguirre

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Losing text in iPad simulator

Post by Klaus » Thu Jun 30, 2011 7:37 pm

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 8)


Best from germany

Klaus

alfredomorai
Posts: 2
Joined: Thu Jun 30, 2011 6:37 pm

Re: Losing text in iPad simulator

Post by alfredomorai » Fri Jul 01, 2011 4:13 am

Klaus,

Thank you very much, now all works fine! :D

Greetings from Mexico,

Alfredo Mora Izaguirre

Post Reply