Javascript panel save txt

Of course, I m a very newbie,
I have a panel wich save my data to a txt file
Now it saves me only var txt1
How to save both variables, txt1 and txt2 to txt file
thank you very

var myWindow = new Window("dialog", "Form");
myWindow.orientation = "column";
myWindow.add("statictext", undefined, "Number:");

var t1 = getData()
var txt1 = myWindow.add("edittext", undefined, t1);

var t2 = getData()
var txt2 = myWindow.add("edittext", undefined, t2);

    var row3 = myWindow.add ("group");
    row3.add("button", undefined, "OK");
    row3.add("button", undefined, "Cancel");
    txt1.onChange = function () {

function getData() {
    var _data = '';
    var _file = File(Folder.myDocuments + "/data.txt");
    if (_file.exists) {"r");
        _data =;
    return _data;

function saveData(text) {
    var _file = File(Folder.myDocuments + "/data.txt");"w");

You have it only for one of the two

yes, is only one…
but the question is
How to include ‘’ txt2’’ to be saved like “txt1”, both în same file(data. txt)

You append it to the existing file, you would just write each bit of data to the same file.

However, as there isn’t any info as to what you’re using here (what provides those functions?) can’t really say what you need to do for that – I assume it’ll just be an extra argument to the write function but :man_shrugging:t3:

this is a simple panel. for now, I would like to save the 2 fields in a text file to retain this numbers for next use…
but it only saves 1 field(230),
how to add the second field (150) in same txt file?


Right, you are using JavaScript, but JS itself doesn’t have the functionality to do that: you are using some library which allows you to do it. But as I don’t know what library that is, it’s quite difficult to give any help. What are Window, Form and Folder?

ok, I understand
I thought they were the same rules…
I use extendscript toolkit

thank you

1 Like

you have this only for txt1, if you want to save both I would expect it also for txt2, or I would exect to see somewhere you concatenate the two as strings