Page 1 of 1

End of file when using readln ? (javascript eof)

Posted: April 6th, 2010, 1:51 pm
by berniebernie
Hello all

I'm using readln to parse a text file line by line (I'd rather not use 'read' if ever I parse a large file), however I have no idea how to catch the end of the file:

Code: Select all

    var myFile = File.openDialog ("Select file","*.txt"); 
    var fileOK = myFile.open("r","TEXT","????");
    while(t = myFile.readln()){
		//alert(t) or whatever
};
The script stops if there's a blank line (two linebreaks).

Any ideas ? Short of using read?

Re: End of file when using readln ? (javascript eof)

Posted: April 6th, 2010, 10:24 pm
by Dan Ebberts
Like this:

Code: Select all

while(! myFile.eof){
      t = myFile.readln();
      //alert(t) or whatever
};
Dan

Re: End of file when using readln ? (javascript eof)

Posted: April 7th, 2010, 1:14 am
by berniebernie
Thank you Dan Ebberts!