Preserving Field Data - confused again!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Preserving Field Data - confused again!
Hi,
I have a stack that has a single card. When run the user may enter some calibration data which I would like to have available when the application is next run. My plan was to build the application as a standalone but the following copied from the dictionary suggests that it is a little more complex ":You cannot save to a standalone application's file; standalones are read-only."
How would you experts store a single value between runs of a standalone?
Thanks
Simon
I have a stack that has a single card. When run the user may enter some calibration data which I would like to have available when the application is next run. My plan was to build the application as a standalone but the following copied from the dictionary suggests that it is a little more complex ":You cannot save to a standalone application's file; standalones are read-only."
How would you experts store a single value between runs of a standalone?
Thanks
Simon
best wishes
Skids
Skids
Re: Preserving Field Data - confused again!
Simon,
a standalone can not save data to itself. There are several options to save data from the standalone. You can save it to a file, which is in the folder where the standalone is. This is a little tricky to find the paths for mac and windows, since they are not the same, you could also save to a folder in the user domain (documents or mydocuments) which you create and control.
What I would suggest is called the splash screen approach. The compiled standalone stack acts as a splash screen, it does not do much except starting, may be showing a, well, splash screen, now the important part: it calls up a second stack that you include in the list of stacks to include when building the standalone, which has all the logic and functionality of your application. The splash screen hides itself.
The beauty of this is that the second stack, with your logic is just a file, not an application. That is why you can save it with changes the user made.
This is explained well in the "Standalones" section of the scripting conferences.
http://support.runrev.com/scriptingconferences/
there you will want to look for: Script Library
You could use your present stack as is and save the calibration data in this stack, just make a splash screen stack that calls your current stack and you are all set.
regards
Bernd
a standalone can not save data to itself. There are several options to save data from the standalone. You can save it to a file, which is in the folder where the standalone is. This is a little tricky to find the paths for mac and windows, since they are not the same, you could also save to a folder in the user domain (documents or mydocuments) which you create and control.
What I would suggest is called the splash screen approach. The compiled standalone stack acts as a splash screen, it does not do much except starting, may be showing a, well, splash screen, now the important part: it calls up a second stack that you include in the list of stacks to include when building the standalone, which has all the logic and functionality of your application. The splash screen hides itself.
The beauty of this is that the second stack, with your logic is just a file, not an application. That is why you can save it with changes the user made.
This is explained well in the "Standalones" section of the scripting conferences.
http://support.runrev.com/scriptingconferences/
there you will want to look for: Script Library
You could use your present stack as is and save the calibration data in this stack, just make a splash screen stack that calls your current stack and you are all set.
regards
Bernd
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Preserving Field Data - confused again!
Bernd,
Thanks yet again for pointing me in the right direction. I have created two stacks and have the process working, which is good
, but I am uncertain how it happens
How and where is the field value saved in the 2nd stack? Indeed where is the second stack once the application is compiled. I'm guessing that the act of compilation adds the "Run" part of the development environment to the stack/s being compiled as the .exe gets quite large but I don't see how an included stack gets written to without there being a file. My head hurts.....
best wishes
Simon
Thanks yet again for pointing me in the right direction. I have created two stacks and have the process working, which is good


best wishes
Simon
- Attachments
-
- Archive 2.zip
- Very simple Splash stack and saving second stack
- (2.71 KiB) Downloaded 231 times
best wishes
Skids
Skids
Re: Preserving Field Data - confused again!
Simon,
no head hurting necessary.
On a Mac your app is actually a folder. If you hold down the control key while clicking on your application a dialog appears and you choose show package content. A new folder opens and it shows your TestApproximator and the TestStack.rev. TestStack.rev is actually a stack = file, which is where your data is saved. That is all. The nice thing about using the stack as a repository of data is you don't have to worry much about where it is. It is right in the application bundle on a Mac and stays there.
I don't know where it is on Windows, but must be similar.
regards
Bernd
no head hurting necessary.
On a Mac your app is actually a folder. If you hold down the control key while clicking on your application a dialog appears and you choose show package content. A new folder opens and it shows your TestApproximator and the TestStack.rev. TestStack.rev is actually a stack = file, which is where your data is saved. That is all. The nice thing about using the stack as a repository of data is you don't have to worry much about where it is. It is right in the application bundle on a Mac and stays there.
I don't know where it is on Windows, but must be similar.
regards
Bernd
- Attachments
-
- Bild 1.png (19.71 KiB) Viewed 4571 times
-
- Posts: 919
- Joined: Wed Nov 04, 2009 11:41 am
Re: Preserving Field Data - confused again!
Bernd,
CLANG - thats the sound of the penny dropping (as we say!)
I have just compiled my application to windows and windows displays the extra stack file alongside the exe file. I had forgotten all about Mac packages ( an idea borrowed from Acorn !Application directories). It is a lot clearer now, thanks again.
Simon
CLANG - thats the sound of the penny dropping (as we say!)

I have just compiled my application to windows and windows displays the extra stack file alongside the exe file. I had forgotten all about Mac packages ( an idea borrowed from Acorn !Application directories). It is a lot clearer now, thanks again.
Simon
best wishes
Skids
Skids
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Preserving Field Data - confused again!
This AppPath function can help you find the path to the app whether running as a standalone on Mac or Win, or even as a stack file within the IDE:
But unfortunately OSes have made it a little harder in recent years for saving as opposed to just reading: Vista, Win 7, and OS X now support multiple user modes, and only administrators will have permission to write to the Program Files or Applications folders.
This article by Sarah Reichelt at revJournal.com shows how to use Rev's specialFolderPath function to find the appropriate user-writable directories to save data on Mac and Win:
http://www.revjournal.com/tutorials/sav ... ution.html
Code: Select all
function AppPath
put the filename of this stack into tPath
set the itemdel to "/"
If (IsOSX()) then
get offset(".app/Contents/MacOS/", tPath)
if it > 0 then -- 2.4.3 or later
delete char it to len(tPath) of tPath
end if
end if
delete last item of tPath
return tPath &"/"
end AppPath
function IsOSX
if the platform is not "MacOS" then return false
get the systemversion
set the itemdel to "."
if item 1 of it >= 10 then return true
return false
end IsOSX
This article by Sarah Reichelt at revJournal.com shows how to use Rev's specialFolderPath function to find the appropriate user-writable directories to save data on Mac and Win:
http://www.revjournal.com/tutorials/sav ... ution.html
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn