Contents of a field not changing in stand alone

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Peacfulrvr
Posts: 34
Joined: Mon Nov 03, 2014 7:11 pm

Contents of a field not changing in stand alone

Post by Peacfulrvr » Mon Dec 15, 2014 5:37 pm

I set up a field and put text into it - then decided to change it later. Now when I save as a standalone and run it on my tablet it still shows the old text that has been changed.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Contents of a field not changing in stand alone

Post by FourthWorld » Mon Dec 15, 2014 5:49 pm

Operating systems do not allow applications to alter themselves - from the standalone building section of the User Guide:
Note: A stack file directly attached to a standalone application cannot have changes saved to it. This stack is bound directly to the executable file that runs. The OS locks an executable file while it is running. If you want to save changes in your standalone application, split your stack up until multiple files. A common technique is to create a "splash screen" stack that contains a welcome screen and then loads the stacks that make up the rest of your application. These stacks are referenced as stackFiles on this pane in the standalone settings screen. It is thus possible to automatically update these component stacks, or to save changes to them. You may also want to consider creating preference files in the appropriate location on your end user's system (see the specialFolderPath function and query/setRegistry functions for more information).
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Peacfulrvr
Posts: 34
Joined: Mon Nov 03, 2014 7:11 pm

Re: Contents of a field not changing in stand alone

Post by Peacfulrvr » Mon Dec 15, 2014 5:54 pm

I uninstall the apk from my tablet and then download and install the new updated apk. The field has been updated in the stack and then saved as a standalone and when I install the new apk it still shows the old field content. I guess I don't understand your answer in light of the fact that I am uninstalling and reinstalling a new apk.

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

Re: Contents of a field not changing in stand alone

Post by Klaus » Mon Dec 15, 2014 5:58 pm

Standalones cannot save themselfes, you need to take care of saving all "user data"
that needs to be available in the next "session", too! 8)

Your standalone will show the text that has been in fields when you "Save as standalone...",
unless you empty your fields on "preopenXXX" resp. fill them again with saved user data.

Basically you do something like in this simplest example, which will save and read in the content of one field:

Code: Select all

on closestack
  ## or whenever you need/want to save data
  save_userdata
end closestack

on openstack
  ## or whenever you need/want to read in saved data
  read_userdata
end openstack

command save_userdata
  ## Create pathname for the data, we have write permissions in this folder:
  put specialfolderpath("documents") & "/user_data.txt" into tFile
  
  ## Now save content of field(s) or whatever needs to be saved
  put fld "user_data" of cd 1 into url("file:" & tFile)
  ## Done :-)
end save_userdata

command read_userdata
  ## Read in saved data
  put specialfolderpath("documents") & "/user_data.txt" into tFile

  ## Now we need to check if we already have saved some data!
  if there is a file tFile then
      put url("file:" & tFile) into fld "user_data" of cd 1
  else
    ## Nothing saved yet, so we should EMPTY the field
    put empty into fld "user_data" of cd 1
end read_userdata
You get the picture :D


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Contents of a field not changing in stand alone

Post by sturgis » Tue Dec 16, 2014 3:25 am

I see what you're saying, though I'm not sure what the answer is.

Well ok, I can think of possibilities. If you have a stackfile saved to a location in the writable directories of your tablet, and are opening the stack with "go stack whatever" its possible (maybe?) that the new one isn't overwriting the old one. But this would pretty much mean you had a loader stack, that you use to fire up other stacks that are saved and savable on the tablet itself. IT doesn't sound like this is what you're doing.

So the next option would be.. Is there code somewhere in your stack that is setting the contents of that field? So even if you manually change it while in the IDE, Save it, Build a standalone, when it then starts up on the tablet, replacing your old apk, there is in your code somewhere, something that sets the contents of that field? If this is the case, you might go through your preopenstack, preopen card, openstack and opencard handlers to look for it.

Barring that, you might zip up and post your stacks here so that we can look at them.
Peacfulrvr wrote:I uninstall the apk from my tablet and then download and install the new updated apk. The field has been updated in the stack and then saved as a standalone and when I install the new apk it still shows the old field content. I guess I don't understand your answer in light of the fact that I am uninstalling and reinstalling a new apk.

Post Reply