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

Save items from a drop-down list

Engaged ,
Feb 03, 2021 Feb 03, 2021

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.jpgexpand image

 

 

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
417
Translate
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

LEGEND , Feb 03, 2021 Feb 03, 2021
with(File('~/desktop/lst.txt')) open('w'), write([1, 2, 3].join('\n')), close()
Translate
Adobe
LEGEND ,
Feb 03, 2021 Feb 03, 2021
with(File('~/desktop/lst.txt')) open('w'), write([1, 2, 3].join('\n')), close()
Translate
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
LEGEND ,
Feb 03, 2021 Feb 03, 2021

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();

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

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

Translate
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