Categories

Reading a textfile line by line

I recently got a question on experts-exchange asking how to read a list of
ids stored in a textfile.

Sample:
———————-
12345
67890
33
56294
———————-
Solution:

The following peice of code will help read a textfile line by line and store
them in the ‘tmp’ array.

myVars = new LoadVars();
myVars.onLoad = onDataload;
myVars.load(“data.txt”);
var tmp;
function onDataload(success) {
for(var i in myVars) {
var data = i
break;
}
tmp = data.split(chr(13)+chr(10));
}

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


two × 5 =