Question

I want to read a local file line by line in JavaScript. Ut I can check if it goes to the end of this file. For example:

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

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

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

While(s != EOF)
{
    //. Do some thing 
    s = f.ReadLine()
}

What is EOF should be in JavaScript? Or do you have another way to deal with this problem? Thank you very much!

Was it helpful?

OTHER TIPS

You're getting back a FileStream object, so you want to use one of the properties that returns boolean to do what you're trying to do, such as AtEndOfStream

However, now I'm going to get out my soapbox and ask why you're writing stuff for windows scripting with javascript, and why you don't choose to use something more modern like PowerShell, which will give you most of the flexibility of .NET objects, but almost all the scriptability of BASH or other scripting languages.

Then the method you're trying to accomplish here would be much easier to write/work with/get support on from other community members.

We're highly unlikely to recall the esoteric specifics of windows jscript programming (but obviously there are a few of us old farts still around)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top