How to load text file into an array and retrieve data line by line?
I am looking for help understanding how to open a text file, load each line to an array. The data will be recalled to change content of text layer. Thank you for any help.
I am looking for help understanding how to open a text file, load each line to an array. The data will be recalled to change content of text layer. Thank you for any help.
// i didn't test this code but something like
var a = [];
var f = new File(Folder.desktop + "/TestFile.txt");
if (f.open('r')) {
while ( ! f.eof) {
a.push(f.readln());
}
f.close();
}
alert("I read " + a.length + " lines from the file.");
for (var i = 0; i < a.length; i++) {
DoSomethingWithThisLine(a); // <-- you need to write this
}
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.