Copy link to clipboard
Copied
I know, The Script File is save setting Like Check Box, Dropdownmenu, Edittext etc..
Can you tell me @JJMack How could you have save setting in script ?
Copy link to clipboard
Copied
Typically you would write settings to a file and read them out again. Extendscript has good XML support.
You can also use the app.preferences object and save a preference setting as
app.preferences.mypref = 'foo';
var bar = app.preferences.mypref;
Copy link to clipboard
Copied
If I have Form Inside a Edittext, I have put 20 in Edittext.
I will change Edittext value :- 24
And Form will close ! and Run Again Form Edittext value will see 24 !
Step 1:- I have Form Inside a Edittext Value is 20
Step 2:- I will Change Edittext Value 24 (Save 24 Value in script)
Step 3:- Again Run Form Edittext value will see 24
Copy link to clipboard
Copied
>>> app.preferences.mypref = 'foo';
>>> var bar = app.preferences.mypref;
What is that? It does not work for me. And why should this work?
Copy link to clipboard
Copied
Putting variable to memory via preferences, so accessing it with next script session? It does not work.
Copy link to clipboard
Copied
Sorry, I was testing in Bridge not photoshop. :sigh: It would be nice if each app had the same capabilities.
In Bridge, you can use the app preferences object to save arbitrary settings. In Photoshop you have to write to a file.
Copy link to clipboard
Copied
I thought so you talk about Bridge, but there you don't have to use preferences to store variables. You can use any variable without connection to preferences. It will be remembered.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I have seen Using Json for saving illustrator script settings. But Can't find exact answar !
Copy link to clipboard
Copied
Why not?
How is the question, such is the answer
There is a solution.
You just need to turn on your head.
Copy link to clipboard
Copied
About a month ago I had to do Save for Web with Month & Day Script? for the very first time. This was my first attempt at writing/reading from a text file.
In this case it is just a simple, single string of text to log save file directory path, that could be referenced in two separate scripts:
/////////////////// WRITE PREFERENCE FILE ///////////////////
// Select the folder to write to the preference file
var prefFilePath = Folder.selectDialog('Select the save folder...', '~/Documents');
// Create the preference file
var prefFile = new File('~/Desktop/Pref-File.txt');
// Write the directory path to the pref file
// r = read mode | w = write mode | a = append | e = edit
prefFile.open('w');
prefFile.write(prefFilePath.fsName);
prefFile.close();
prefFile.encoding = 'UTF-8';
// LineFeed options
// prefFile.lineFeed = "Unix";
// prefFile.lineFeed = "Windows";
// prefFile.lineFeed = "Macintosh";
// Alert notice
alert('Save path written to Desktop log file "Pref-File.txt"');
////////////////////////////////////////////////////////////
/////////////////// READ PREFERENCE FILE ///////////////////
// Pref file location
var prefFile = File('~/Desktop/Pref-File.txt');
// Open the pref file: r = read mode | w = write mode | a = append | e = edit
var openPrefFile = prefFile.open('r');
// Read the value
var prefFileValue = prefFile.readln();
// Pref file value returned
alert('Save folder location:' + '\r' + prefFileValue);
////////////////////////////////////////////////////////////
Perhaps one day I'll need to graduate to a JSON or XML file, however I was just happy to get a plain text file working in this case!
Copy link to clipboard
Copied
I have seen pref file, I know How to write on text file in Script ,
My Question is i have txtbox value already exists.it must alert that it was already exists.else save data.
suppose,
prefs.txtbox = "AS"
//button clicked it saved
*************************
then again
prefs.txtbox = "AS"
//button clicked alert "already exists"
Copy link to clipboard
Copied
So why not use an if or while conditional to check if var equals value?
Copy link to clipboard
Copied
At some point I'll post a sample script with reading/writing XML values to save prefs. I used that for quite a while so I have a working implementation that just needs packaging.
Copy link to clipboard
Copied
Thank you, that would be very useful!
Copy link to clipboard
Copied
I added an "XMLPrefs" script to my dropbox folder. It has sample code for reading/writing prefs to an XML file.