Click to See Complete Forum and Search --> : How to check for end of file??


Fred Flintstone
04-25-2003, 12:20 PM
Hello!

I was wondering if anyone knows how to check for the "end-of-file" using Javascript and Active X.

I want to perform a while loop using the condition "while not end-of-file". Unfortunately, EOF, eof, EOF(), eof()... do not work at all in Microsoft internet explorer 6.

Here is part of my code:

// This creates a new Active X Object in order to read in a file.

file = new ActiveXObject("Scripting.FileSystemObject");

// Sets the variable "f" to equal the new open file contents

f = file.OpenTextFile("c:\\wantlist.txt", 1);

/* This SHOULD keep looping until it reaches the end of the file but doesn't!! It actually keeps looping without correctly checking the condition until a javascript error pops up saying it's already reached the end of file when it tries to read in the line. */

while(!line.EOF())
{
line = f.ReadLine();
}

Anyone know the correct syntax for checking an End-of-file for Javascript using Microsoft Internet Explorer 6 and up??

I'd appreciate any help!

khalidali63
04-25-2003, 12:24 PM
This message is well suited for ASP forum.. its Moved to ASP forum.

Jona
04-25-2003, 12:43 PM
You could try using: line = f.ReadAll(); instead of worrying about your while() loop...

Fred Flintstone
04-25-2003, 12:44 PM
Why was this moved to the asp forum?
My code does not involve any ASP and I'm not using ASP.

Fred Flintstone
04-25-2003, 12:48 PM
Originally posted by Jona
You could try using: line = f.ReadAll(); instead of worrying about your while() loop...

But I have additional code inside the while loop which needs to be checked line by line. I just wrote "line = f.ReadLine();" to simplify it.

I've already figured out a way around this. But I just want to know if there is any keyword or function like .EOF() to check for the end of file.

Jona
04-25-2003, 01:09 PM
I've looked and not found anything such as what you're looking for...

Fred Flintstone
04-25-2003, 02:41 PM
Originally posted by Jona
I've looked and not found anything such as what you're looking for...

Thanks anyway!

Fred Flintstone
04-25-2003, 09:24 PM
I originally found snippets of the code that I used in my script from various sources. I was not aware of the Microsoft developer's library help site at all though. I appreciate the link! Thanks!