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

Save items from a drop-down list

Engaged ,
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

402

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

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

Votes

Translate

Translate
Adobe
LEGEND ,
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()

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

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

Copy link to clipboard

Copied

LATEST

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

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