Page 1 of 1
Contents of a field not changing in stand alone
Posted: Mon Dec 15, 2014 5:37 pm
by Peacfulrvr
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.
Re: Contents of a field not changing in stand alone
Posted: Mon Dec 15, 2014 5:49 pm
by FourthWorld
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).
Re: Contents of a field not changing in stand alone
Posted: Mon Dec 15, 2014 5:54 pm
by Peacfulrvr
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.
Re: Contents of a field not changing in stand alone
Posted: Mon Dec 15, 2014 5:58 pm
by Klaus
Standalones cannot save themselfes, you need to take care of saving all "user data"
that needs to be available in the next "session", too!
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
Best
Klaus
Re: Contents of a field not changing in stand alone
Posted: Tue Dec 16, 2014 3:25 am
by sturgis
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.