• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

save value edittext

Advocate ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Good morning

I'm having a problem storing the edittext value in the .ini file

in the preset folder

I would like the value placed in the edittext window to be stored in the .ini file

where am I wrong?

function readini() {

    var SCRIPTS_FOLDER = new Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));

    ini=new File([SCRIPTS_FOLDER + "/Memory.ini"]);

    if (ini.created) {

        $.evalFile(ini);

        return true;

    };

    ini.close();

};

  app.displayDialogs = DialogModes.NO; 

app.preferences.rulerUnits = Units.PIXELS; 

 

var win = new Window('dialog', 'IMAGE DIMENSION',[100,100,300,300]);  

win.msgPnl = win.add('panel', [25,15,180,195], 'OPTION');  

win.msgPnl.titleSt = win.msgPnl.add('statictext', [15,15,130,35], 'DIMENSION PX:'); 

win.msgPnl.titleEt = win.msgPnl.add('edittext', [15,45,115,65], '1920');  

win.buttonRef = win.msgPnl.add('button',  [15, 70, 115, 95] , 'APPLY', { name:'ok'}); 

win.msgPnl.cancelBtn = win.msgPnl.add('button', [15,105,115,130],'CANCEL', {name:'cancel'});

win.buttonsave = win.msgPnl.add('button',  [15, 140, 115, 165] , 'SAVE PRESET', { name:'ok'}); 

win.buttonsave.onClick = function(){

    ini.open('w');

    ini.writeln("win.msgPnl.titleEt  =" ,Math.floor(msgPnl));

    ini.close();

};

/*

if (readini()) {

    if (msgPnl) {

       win.msgPnl.titleEt =msgPnl;

       win.msgPnl.titleEt .text=msgPnl;

    };

}

*/

win.buttonRef.onClick = function(){ 

    win.close(0); 

win.center(); 

win.show() 

TOPICS
Actions and scripting

Views

1.4K

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

correct answers 1 Correct answer

Guide , Oct 01, 2017 Oct 01, 2017

This is one way...

#target photoshop;

app.bringToFront();

app.displayDialogs = DialogModes.NO;   

app.preferences.rulerUnits = Units.PIXELS; 

var SCRIPTS_FOLDER = new Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")); 

//alternative folder

//  var SCRIPTS_FOLDER  = new Folder(Folder.userData + "/Adobe/Adobe Photoshop CS6/presets/scripts");

    if(!SCRIPTS_FOLDER.exists) SCRIPTS_FOLDER.create();

     ini=new File(SCRIPTS_FOLDER + "/Memory.ini");

     var data='

...

Votes

Translate

Translate
Adobe
Guide ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Are you on Windows or Mac?

If you are using Windows you do not have write permission to that folder.

Votes

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
Advocate ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Use both windows and mac.

Votes

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
Guide ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

In that case use a different folder IE.

//amend for Photoshop Version !

var FileFolder = Folder(Folder.userData + "/Adobe/Adobe Photoshop CS6/presets/scripts");

if(!FileFolder.exists) FileFolder.create();

Votes

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
Advocate ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

SuperMerlin

the memory.ini file creates it

but does not store the value of edittext.

Votes

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
Guide ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

You have a few errors!

win.buttonsave.onClick = function(){ 

    var SCRIPTS_FOLDER = new Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));

    //var SCRIPTS_FOLDER  = new Folder(Folder.userData + "/Adobe/Adobe Photoshop CS6/presets/scripts");

    ini=new File(SCRIPTS_FOLDER + "/Memory.ini");

    ini.open('w'); 

    ini.writeln("win.msgPnl.titleEt  = " + Math.floor(Number(win.msgPnl.titleEt.text))); 

    ini.close(); 

};

This function did not know where ini was plus you were not writing a valid string.

Votes

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
Advocate ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Ok the first step is done

the value is stored in the memory.ini file

i in edittext i put the value 1032

this value has been saved in memory.ini correctly

this and the value

win.msgPnl.titleEt = 1032

now i would like it when I reopen the dialog box

the stored value is displayed in the edittext window.

as in this image

1123.jpg

Votes

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
Guide ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

This is one way...

#target photoshop;

app.bringToFront();

app.displayDialogs = DialogModes.NO;   

app.preferences.rulerUnits = Units.PIXELS; 

var SCRIPTS_FOLDER = new Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts")); 

//alternative folder

//  var SCRIPTS_FOLDER  = new Folder(Folder.userData + "/Adobe/Adobe Photoshop CS6/presets/scripts");

    if(!SCRIPTS_FOLDER.exists) SCRIPTS_FOLDER.create();

     ini=new File(SCRIPTS_FOLDER + "/Memory.ini");

     var data='';

    if (ini.exists) { 

       ini.open('r'); 

       data = ini.read().match(/\S+/g);

        ini.close();

    };   

var win = new Window('dialog', 'IMAGE DIMENSION',[100,100,300,300]);     

win.msgPnl = win.add('panel', [25,15,180,195], 'OPTION');    

win.msgPnl.titleSt = win.msgPnl.add('statictext', [15,15,130,35], 'DIMENSION PX:');   

win.msgPnl.titleEt = win.msgPnl.add('edittext', [15,45,115,65], '1920');    

win.buttonRef = win.msgPnl.add('button',  [15, 70, 115, 95] , 'APPLY', { name:'ok'});   

win.msgPnl.cancelBtn = win.msgPnl.add('button', [15,105,115,130],'CANCEL', {name:'cancel'}); 

win.buttonsave = win.msgPnl.add('button',  [15, 140, 115, 165] , 'SAVE PRESET', { name:'ok'});   

if(data != '')  win.msgPnl.titleEt.text = data[data.length -1];

 

win.buttonsave.onClick = function(){ 

    ini.open('w'); 

    ini.writeln("win.msgPnl.titleEt  = " + Math.floor(Number(win.msgPnl.titleEt.text))); 

    ini.close(); 

}; 

win.buttonRef.onClick = function(){   

    win.close(0);   

}   

win.center();   

win.show();

Votes

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
Advocate ,
Oct 01, 2017 Oct 01, 2017

Copy link to clipboard

Copied

Thank you

just what I was looking for.

Votes

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
Advocate ,
Oct 12, 2018 Oct 12, 2018

Copy link to clipboard

Copied

LATEST

Now I need to memorize the text

unfortunately with the text it does not work

what must be changed to make it work properly

// SCRIPT

app.bringToFront(); 

 

app.displayDialogs = DialogModes.NO;     

app.preferences.rulerUnits = Units.PIXELS;   

var SCRIPTS_FOLDER = new Folder(app.path + '/' + localize("$$$/ScriptingSupport/InstalledScripts=Presets/Scripts"));   

//alternative folder 

//  var SCRIPTS_FOLDER  = new Folder(Folder.userData + "/Adobe/Adobe Photoshop CS6/presets/scripts"); 

    if(!SCRIPTS_FOLDER.exists) SCRIPTS_FOLDER.create(); 

     ini=new File(SCRIPTS_FOLDER + "/Memory.ini");  

     var data=''; 

    if (ini.exists) {   

       ini.open('r');   

       data = ini.read().match(/\S+/g); 

        ini.close(); 

    };     

var win = new Window('dialog', 'MEMORY TEXT',[100,100,300,300]);       

win.msgPnl = win.add('panel', [25,15,180,195], 'OPTION');      

win.msgPnl.titleSt = win.msgPnl.add('statictext', [15,15,130,35], 'DIMENSION PX:');     

win.msgPnl.titleEt = win.msgPnl.add('edittext', [15,45,115,65], 'TEXT TEST ');      

win.buttonRef = win.msgPnl.add('button',  [15, 70, 115, 95] , 'APPLY', { name:'ok'});     

win.msgPnl.cancelBtn = win.msgPnl.add('button', [15,105,115,130],'CANCEL', {name:'cancel'});   

win.buttonsave = win.msgPnl.add('button',  [15, 140, 115, 165] , 'SAVE PRESET', { name:'ok'});     

if(data != '')  win.msgPnl.titleEt.text = data[data.length -1]; 

   

win.buttonsave.onClick = function(){   

    ini.open('w');   

    ini.writeln("win.msgPnl.titleEt  = " + Math.floor(Number(win.msgPnl.titleEt.text)));   

    ini.close();   

};   

win.buttonRef.onClick = function(){     

    win.close(0);     

}     

win.center();     

win.show();  

Votes

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