Saving User Preferences - and using them
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Saving User Preferences - and using them
The "Getting Started" example
"Preferences pane-saving to a stack or text file"
in "Ten functional examples"
doesn't go into much detail about reading
the user preferences at startup.
Anyone know of any further info on
the subject?
"Preferences pane-saving to a stack or text file"
in "Ten functional examples"
doesn't go into much detail about reading
the user preferences at startup.
Anyone know of any further info on
the subject?
Life is just a bowl of cherries.
Here is an example of what I am using in a stack to read a txt at startup:
You can of course have multiple put statements using the text chunking that best fits how you saved to the file in the first place.
Code: Select all
on openStack
if there is a file "C:/Documents and Settings/All Users/Application Data/CK/settings.txt" then
put line 1 of url "file:C:/Documents and Settings/All Users/Application Data/CK/settings.txt" into fld "audURL" of stack "settings"
else
Answer information "Settings are at default"
end if
end openStack
Saving is a doddle too:
Code: Select all
put the value of fld "theSize" of stack "Image" into line 1 of URL "file:preferences.txt"
Saving User Preferences - and using them
I was thinking more along the lines
of reading from a text file into a
variable.
I expect it's possible. As I get annoyed
by programmes which give a message like
"New settings will take effect when you
restart" I wanted to perhaps read the
settings each time they're used so that
changes take effect immediately.
Or perhaps in the case of a number of
settings read them into an array and
access them from there.
Did think of checking the date/time of the
settings file each time but that's probably
no more efficient that reading the vars.
each time they're used (which would
be quite often).
Could also set a true/false when used
changes a setting.....
Lots of possibilities. My question came
from feeling that it seemed too easy!
of reading from a text file into a
variable.
I expect it's possible. As I get annoyed
by programmes which give a message like
"New settings will take effect when you
restart" I wanted to perhaps read the
settings each time they're used so that
changes take effect immediately.
Or perhaps in the case of a number of
settings read them into an array and
access them from there.
Did think of checking the date/time of the
settings file each time but that's probably
no more efficient that reading the vars.
each time they're used (which would
be quite often).
Could also set a true/false when used
changes a setting.....
Lots of possibilities. My question came
from feeling that it seemed too easy!
Life is just a bowl of cherries.
So use a variable instead of a Field as in our examples. Probably just extra code though as fields make great containers and you need them anyway for settings changes.
As far as when to trigger this, you really only need to do it on stack open and stack close. As the settings changes user makes during runtime can be active right away.
Your description of doing this by checking the time is easy to do, but personally sounds over engineered. If you want to have it saved to the txt right away, I would just trigger it on change of the setting, clean and simple.
As far as when to trigger this, you really only need to do it on stack open and stack close. As the settings changes user makes during runtime can be active right away.
Your description of doing this by checking the time is easy to do, but personally sounds over engineered. If you want to have it saved to the txt right away, I would just trigger it on change of the setting, clean and simple.
Saving User Preferences - and using them
Right, keyless.
On giving the matter further thought I
did come to the conclusion that new
settings would be used during the
current session and could then
be saved at close.
Thanks for your input.
On giving the matter further thought I
did come to the conclusion that new
settings would be used during the
current session and could then
be saved at close.
Thanks for your input.
Life is just a bowl of cherries.