Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to Save Setting in Script

Participant ,
Jul 14, 2021 Jul 14, 2021

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 ?

TOPICS
Actions and scripting

Views

241

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

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;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 14, 2021 Jul 14, 2021

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 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

>>> app.preferences.mypref = 'foo';

>>> var bar = app.preferences.mypref;

Lumigraphics

What is that? It does not work for me. And why should this work?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Putting variable to memory via preferences, so accessing it with next script session? It does not work.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

Copy link to clipboard

Copied

Untitled-2.png

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

I have seen Using Json for saving illustrator script settings. But Can't find exact answar !

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 14, 2021 Jul 14, 2021

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!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jul 15, 2021 Jul 15, 2021

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"

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

So why not use an if  or while conditional to check if var equals value?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 15, 2021 Jul 15, 2021

Copy link to clipboard

Copied

Thank you, that would be very useful!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 16, 2021 Jul 16, 2021

Copy link to clipboard

Copied

LATEST

I added an "XMLPrefs" script to my dropbox folder. It has sample code for reading/writing prefs to an XML file.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines