TextStream: ReadLine - how to detect eof 
Author Message
 TextStream: ReadLine - how to detect eof

I have a script to read lines from a text file. I need to loop until
it reaches the end of the file. Does anyone know how to detect the end
of a text file?

 Dim fso, file, ts...
 Set fso = CreateObject("Scripting.FileSystemObject")
 Set file = fso.GetFile("file.txt")
 Set ts = file.OpenAsTextStream(1, -2) '// for reading,
tristate-default

 Do
    strLine = ts.ReadLine
    ...
 Loop Until strLine <> eof '<-how to detect end of the file?



Sat, 29 Mar 2003 03:00:00 GMT  
 TextStream: ReadLine - how to detect eof

I just learned that:

Do While f.AtEndOfStream <> True
      s = f.ReadLine
      ...
Loop


Quote:
> I have a script to read lines from a text file. I need to loop until
> it reaches the end of the file. Does anyone know how to detect the end
> of a text file?

>  Dim fso, file, ts...
>  Set fso = CreateObject("Scripting.FileSystemObject")
>  Set file = fso.GetFile("file.txt")
>  Set ts = file.OpenAsTextStream(1, -2) '// for reading,
> tristate-default

>  Do
>     strLine = ts.ReadLine
>     ...
>  Loop Until strLine <> eof '<-how to detect end of the file?



Sat, 29 Mar 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. TextStream object and ReadLine property

2. Using the ReadLine method for TextStream object

3. TextStream: progress indication with ReadLine?

4. Readline until EOF

5. file handling - how do i detect eof

6. Detect EOF viewed in RichTextBox?

7. Detecting EOF for Excel file using Excel Application Object

8. Using the FileOpen dialog to find a file to open so I can use ReadLine method

9. --> StreamReader.Readline problem

10. ReadLine, socket disconnect

11. Readline only read first character in line

12. StreamReader.ReadLine to ignore carriage returns?

 

 
Powered by phpBB® Forum Software