Save custom attributes in standalone
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Save custom attributes in standalone
if i want to have some settings save for the next time i open the program without saving them to an external file how can i do it?
Re: Save custom attributes in standalone
Simple answer: you can't. A standalone cannot modify itself. You can easily write to an external file on exit, and read in on starting up again. The external file can be a livecode stack too.
Additionally you can extend this idea to have a standalone that is just a launcher for your application which is a native livecode stack. Look up "splashstack technique" for more specifics.
Additionally you can extend this idea to have a standalone that is just a launcher for your application which is a native livecode stack. Look up "splashstack technique" for more specifics.
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Save custom attributes in standalone
Hi.
First you must know that the executable cannot save to itself. So any such settings must be stored either in another stack or in an external file. Are you familiar with both of these methods?
Craig Newman
First you must know that the executable cannot save to itself. So any such settings must be stored either in another stack or in an external file. Are you familiar with both of these methods?
Craig Newman
Re: Save custom attributes in standalone
looks like it will have to be external file i guess
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Save custom attributes in standalone
I always use the "splash" stack method, using external files seldomly
Invariably it is in the "working" stack(s) where I store properties and other data, and these are saved between sessions. I find this more comforting and accessible than using external files.
Unless I misunderstand what you meant by:
Craig
Invariably it is in the "working" stack(s) where I store properties and other data, and these are saved between sessions. I find this more comforting and accessible than using external files.
Unless I misunderstand what you meant by:
you can almost certainly keep whatever settings you like within your (working) stack.looks like it will have to be external file i guess
Craig
Re: Save custom attributes in standalone
Ok. So my program has need of a database. When the program first runs if it can't find a database, it will go to a card where the user puts in his database name, username and password. The database is then created and I want those settings saved so that whenever the program runs it has the right database name, username and password to use. I would love it if they were saved in the program as opposed to an external file
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Save custom attributes in standalone
OK.
So save all those preferences in a custom property of the stack. This is simple and straightforward unless we still do not grok the "Splash" thing.
Craig
So save all those preferences in a custom property of the stack. This is simple and straightforward unless we still do not grok the "Splash" thing.
Craig
Re: Save custom attributes in standalone
Hi friends,
please don't forget that if the app/exe has been installed into the "correct" place ("Applications" on Mac and "Programm files..." on Windows)
only users with ADMIN permissions are allowed to write (= save a stack or anything else) in that directory!
Best
Klaus
please don't forget that if the app/exe has been installed into the "correct" place ("Applications" on Mac and "Programm files..." on Windows)
only users with ADMIN permissions are allowed to write (= save a stack or anything else) in that directory!
Best
Klaus
Re: Save custom attributes in standalone
dunbarx how do i save to a stack AFTER the program has been compiled to a standalone is the question
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Save custom attributes in standalone
You make a small stack that may have absolutely nothing on it or in it. Name it "splash".
In the standalone settings for this stack you can add other stack files to your heart's content . Those stack files contain "working" stacks (and substacks).
The stack "splash", upon opening, navigates to one or more of those other stacks. It can hide itself. ALL those other stacks can save their data between sessions. So the splash stack becomes the executable, "carrying" along with it other stacks that actually do the stuff you likely worked in the IDE.
In the IDE, you might liken it to the engine (LC itself) being the executable and any old stack you mess around with being the "working' stack. This analogy maps to a standalone, in that the splash stack is LC, and its attached stack files are the ordinary stacks that you play with.
Craig
In the standalone settings for this stack you can add other stack files to your heart's content . Those stack files contain "working" stacks (and substacks).
The stack "splash", upon opening, navigates to one or more of those other stacks. It can hide itself. ALL those other stacks can save their data between sessions. So the splash stack becomes the executable, "carrying" along with it other stacks that actually do the stuff you likely worked in the IDE.
In the IDE, you might liken it to the engine (LC itself) being the executable and any old stack you mess around with being the "working' stack. This analogy maps to a standalone, in that the splash stack is LC, and its attached stack files are the ordinary stacks that you play with.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Save custom attributes in standalone
Where will the database be stored?Da_Elf wrote:Ok. So my program has need of a database. When the program first runs if it can't find a database, it will go to a card where the user puts in his database name, username and password. The database is then created and I want those settings saved so that whenever the program runs it has the right database name, username and password to use. I would love it if they were saved in the program as opposed to an external file
As for the login credentials, you might as well save those to a separate file. There are ways to save the UI stack file itself, but with two trade-offs for doing so:
1. If you later update the UI in a future version you'll need to work out some way to get the data from the old stack before replacing it. For any app expected to live beyond one version, it's usually simpler to separate UI and data.
2. The data are login credentials, which should be stored encrypted on disk. There are clever ways to do this with stack files, but it's a lot of extra work.
Probably simpler to just package up the login data into a string, use the built-in encrypt command to encrypt the data, then write that to disk. When launching next time, read the data, use the decrypt command on it, then populate those three fields.
LiveCode's specialFolderPath function can be useful here. It accepts a variety of constants for different standard folders, such as specialFolderPath("Preferences"), which can then be appended with the name of the file you're using to store the data so your app can find it again next time it opens.
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
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Save custom attributes in standalone
Do you mean you already have a standalone, and want to modify it to allow data to be saved? That is not possible if the standalone is the executable. You have to modify the original stack(s) oin the IDE and save anew.dunbarx how do i save to a stack AFTER the program has been compiled to a standalone is the question
Craig
Re: Save custom attributes in standalone
fourthworld the database is a mySQL database stored locally in its default installed folder
dunbarx exactly. Ive created the whole program and exported as a standalone. When i put it on a computer and run it for the first time it goes to a setup page which will ask for my user information for this particular instance. It will use this information to create a mySQL database based on these preferences. I want to be able to save the database info at this point. Then once the setup is done it enters the main part of the software and uses the info. Each time after the 1st running i would like it to skip the setup because it will see that data is there. It will go direct to the main part and use the preferences as before.
dunbarx exactly. Ive created the whole program and exported as a standalone. When i put it on a computer and run it for the first time it goes to a setup page which will ask for my user information for this particular instance. It will use this information to create a mySQL database based on these preferences. I want to be able to save the database info at this point. Then once the setup is done it enters the main part of the software and uses the info. Each time after the 1st running i would like it to skip the setup because it will see that data is there. It will go direct to the main part and use the preferences as before.
-
- VIP Livecode Opensource Backer
- Posts: 9838
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: Save custom attributes in standalone
Did you mean SQLite? MySQL runs as a separate process, and unless your app is licensed under GPL there are licensing fees for distributing the MySQL dp package.
Either way, unless this is a one-off quickie app I think you'll find it easier over the long haul to just write that small login into to a small file in a default location.
Either way, unless this is a one-off quickie app I think you'll find it easier over the long haul to just write that small login into to a small file in a default location.
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
Re: Save custom attributes in standalone
fouthworld im using mysql community on a local machine. My software isnt designed to be on the market or anything (im not that good yet). Ive just created some apps for my friends to use which use a database and since im used to using mysql online with PHP i thought what the hell. ill just install locally. I did look in to mysql lite but there were some things it couldnt do that mysql could do (i cant remember what they are now). Its looking like i will just end up using an external file which i will encrypt the information so no one can read it.