How can a make a .txt file to save user input data after each use? I would like to save or store the "width" and "height" var until the next input.
var doc = app.activeDocument;
var panel = new Window("dialog", "test", undefined, { borderless: false });
var row1 = panel.add ("group");
row1.add ('statictext {text: "width", characters: 8, justify: "left"}');
var width = row1.add("edittext",undefined, "100");
width.characters = 10;
var row2 = panel.add ("group");
row2.add ('statictext {text: "height", characters: 8, justify: "left"}');
var height = row2.add("edittext",undefined,"200");
height.characters = 10;
var row3 = panel.add ("group");
row3.add("button", undefined, "OK");
row3.add("button", undefined, "Cancel");
panel.show();
x = Number(width.text + " ");
i = Number(height.text + " ");
var layer = doc.layers[0];
var rectangle;
rectangle = layer.pathItems.rectangle(0, 0, x, i);
JSON.stringify( myVar )
and thenJSON.parse( text )
. JSON extension is.json
. I think you still need to manually add JSON to your project to use the mentioned JSON methods, but I'm not sure if that's changed in the newer CC versions.width,height
→122,300
and readtext.split(',')
. — This might not be necessary looking at your dialog, but perhaps it's useful in the future... I have made a ScriptUI dialog builder that basically tries to solve the issue of designing the dialog and it also exports working javascript code for SUI.app.preferences.setStringPreference('yourscript/subvalue',"data");