Skip to main content
Participant
July 12, 2021
Answered

Can't show alert name in the txt file, please help

  • July 12, 2021
  • 1 reply
  • 374 views

 

var txt = File("~/Desktop/xpanel.txt");
txt.open('r');
var str = txt.read();
if(str.length>0){
  var names = "";
  for (var i = 0; i < str.length; i++) {
    if (i==0 )   names =  tr.split(',') + decodeURI(str[i].name);
  }
alert(name);
}

 

File txt xpanel.txt

 

images1,images2,images3,images4,...,imagesn

 

I wrote something wrong but can't show alert with correct name in xpanel.txt, please help

This topic has been closed for replies.
Correct answer Kukurykus
with(File('~/Desktop/xpanel.txt')) length &&
(open('r'), s = read(), close(), arr = s.split(','))
&& (function(){while(arr.length) alert(arr.shift())})()

1 reply

Kukurykus
Legend
July 12, 2021

 

with(File('~/Desktop/xpanel.txt')) length &&
(open('r'), s = read(), close(), alert(s.split(',')))

 

XpanelAuthor
Participant
July 12, 2021

the code is wrong, I want it to loop alert each name in file xpanel

Kukurykus
KukurykusCorrect answer
Legend
July 12, 2021
with(File('~/Desktop/xpanel.txt')) length &&
(open('r'), s = read(), close(), arr = s.split(','))
&& (function(){while(arr.length) alert(arr.shift())})()