Save items from a drop-down list

Contributor ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

Still on the topic dropdown list.
Kukurykus  or r-bin how do I save all the list items in a.txt file so that each item is on different lines without the comma.
The best I could do was save just one line. Thanks again.

0001.jpg

 

 

var dlg = new Window("dialog"); 
var conteudo = ["Item 1","Item 2","Item 3","Item 4","Item 5"]; 
var list = dlg.add("dropdownlist", undefined, undefined, {name: "list", items: conteudo}); 
list.selection= 0;

savelistatxt()

function savelistatxt(){
    var selectedFolder = conteudo;
    if(selectedFolder == null) return;
    var fileList= list.items;
    if(fileList.length>0){
    var out = new File(Folder.desktop + "/ListIcons.txt");
    out.open("w");
    out.encoding="UTF8";
    for(var a in fileList){out.writeln(fileList);}   
    out.close();
    }
};

dlg.show();

 

 

TOPICS
Actions and scripting

Views

126

Likes

translate

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

Adobe Community Professional , Feb 03, 2021 Feb 03, 2021
with(File('~/desktop/lst.txt')) open('w'), write([1, 2, 3].join('\n')), close()

Likes

translate

Translate

Translate
Adobe Community Professional ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

with(File('~/desktop/lst.txt')) open('w'), write([1, 2, 3].join('\n')), close()

Likes

translate

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 ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

var dlg = new Window("dialog");
var conteudo = ["Item 1","Item 2","Item 3","Item 4","Item 5"];
var list = dlg.add("dropdownlist", undefined, undefined, {name: "list", items: conteudo});
list.selection= 0;

savelistatxt()

function savelistatxt(){
var selectedFolder = conteudo;
if(selectedFolder == null) return;
var fileList= list.items;
if(fileList.length>0){
var out = new File(Folder.desktop + "/ListIcons.txt");
out.open("w");
out.encoding="UTF8";
for(var a = 0; a < fileList.length; a++){
out.writeln(fileList[a]);
}
out.close();
}
};

dlg.show();

Likes

translate

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
Contributor ,
Feb 03, 2021 Feb 03, 2021

Copy link to clipboard

Copied

Perfect! Both scripts worked very well! Thanks to the two friends for sharing their knowledge.

Likes

translate

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