Hi,
basically, I have an "edittext" box and a "chose" button, so user could select the path on hard drive which would be processed later in the script. My question is, can that path (which is a string value) stay unchanged, for the next script launch? so whatever user chose it will stay there, no matter how many times the script was launched. until he changes it again...
can it be done (in ExtendScript)?
thanks
store variables locally on hdd or direcly in .js file?
Moderator: Paul Tuersley
-
- Posts: 81
- Joined: November 27th, 2012, 6:41 am
Storing in the .jsx itself is maybe possible but there are simpler ways: use the app.settings object.
It has 3 methods: haveSetting, getSetting, saveSetting.
if (app.settings.haveSetting(sectionTag, keyTag))
{
var setting = app.settings.getSetting(sectionTag, keyTag);
// then parse the string and distribute values to your variable(s)
}
else {// give default values to your variable(s)}
Upon quitting (or whatever event), to save a setting you must:
convert your variable(s) into a string str,
then app.settings.saveSetting(sectionTag, keyTag, str);
sectionTag and keyTag are string identifiers that you can choose (for instance sectionTag = "My_Script_Name" and keyTag = "My_Variable_Name");
It has 3 methods: haveSetting, getSetting, saveSetting.
- haveSetting check if a setting exists
- saveSetting saves directly in the user's Preferences.txt file of the application.
- getSetting retrieves that setting and returns it, always as a STRING (whatever you want to do with it)
if (app.settings.haveSetting(sectionTag, keyTag))
{
var setting = app.settings.getSetting(sectionTag, keyTag);
// then parse the string and distribute values to your variable(s)
}
else {// give default values to your variable(s)}
Upon quitting (or whatever event), to save a setting you must:
convert your variable(s) into a string str,
then app.settings.saveSetting(sectionTag, keyTag, str);
sectionTag and keyTag are string identifiers that you can choose (for instance sectionTag = "My_Script_Name" and keyTag = "My_Variable_Name");
-
- Posts: 6
- Joined: November 3rd, 2013, 4:00 pm
yup, this works perfectly! I didn't paid enough attention in the scripting guide...
thanks for the very detailed answer.
endUndoGroup
thanks for the very detailed answer.
endUndoGroup