How do I save custom properties in a standalone application?
Custom properties are a very useful way to store information, and if you want that information to persist between sessions you can just save your stack and the custom properties are saved and available next time you start it up. But what if you want to use and save custom properties once you have built your application into a standalone?
In this lesson we will learn how to create a standalone application consisting of a launcher and an editable file.
The launcher and the main stack
Creating the launcher
The launcher stack will be built into a standalone and all we need it to do is to open our main application, it can then close itself. Add the following script to the stack script of the launcher stack.
open stack "Main Application.livecode"
close stack "Launcher"
Thats all we need to do. The launcher will then open the Main Application stack, which can be modified and saved as it is not a standalone.
Adding some script to the main application
Now we need a simple test to check that our Main Application can be saved and that custom properties are preserved.
Lets use our name as an example. We will add a field to type your name into (1), a button which saves the name as a custom property (2) and another button which displays the saved name using an answer dialog. (3)
The Save Name button just stores the name in a custom property
set the cName of this stack to field "name"
put empty into field "name"
The Display Name button uses an answer dialog to display the name saved in the custom property
answer the cName of this stack
Saving the stack
In order to preserve the custom property cName we need to save our Main Application stack when it is closed. Add the following script to the stack script of the Main Application stack
save this stack
This means any changes we have made to the stack, including our custom property are saved.