Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Input Past end of file error

Status
Not open for further replies.

incron

Technical User
Mar 16, 2002
60
US
Hey Guys look at this code snippet:




Const ForReading = 1, ForWriting = 2, ForAppending = 8


DIM objFile, strFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
strFile = "UIFileSpecs.txt"
Set objFile = objFSO.OpenTextFile(strFile, ForReading)




Do While Not objFile.AtEndOfStream




'Line 1 contains the age in days of the files were looking for
For i = 0 to 1
objFile.ReadLine
Next

StrAgeOfFile = objFile.ReadLine



'Line 2 contains the 2nd extension of the files were looking for
For i = 1 to 2
objFile.ReadLine
Next

StrExtension1 = objFile.ReadLine




'Line 3 contains the 3rd extension of the files were looking for

For i = 2 to 3
objFile.ReadLine
Next

StrExtension3 = objFile.ReadLine




'Line 4 contains the 4th extension of the files were looking for

For i = 3 to 4
objFile.ReadLine
Next

StrExtension4 = objFile.ReadLine





'Line 5 contains the 5th extension of the files were looking for

For i = 4 to 5
objFile.ReadLine
Next

StrExtension5 = objFile.ReadLine







'Line 6 contains the 6th extension of the files were looking for

For i = 5 to 6
objFile.ReadLine
Next

StrExtension6 = objFile.ReadLine





I am scanning and assigning variables for each line - 50 of them in fact. In the text file being scanned for this test there are only 6 lines. But even though I have the Do While Not objFile.AtEndOfStream at the beginning and though you cant see it here, I do have the Loop terminator at the end of the code. I keep getting the following error after the 3rd line in the text file:

---------------------------
Windows Script Host
---------------------------
Script: E:\MasterMkDirTemplateExtByDte.vbs
Line: 50
Char: 5
Error: Input past end of file
Code: 800A003E
Source: Microsoft VBScript runtime error

---------------------------
OK
---------------------------



Any ideas...???
 
You have a very strange image of how line is counted. This is the line numbering.
[tt]
i=0
Do While Not objFile.AtEndOfStream
i=i+1
s=objFile.readline 's is storing line i as read
'do whatever with s
Loop
[/tt]
 
Thanks tsuji

It was right in front of my face I forgot to increment the i variable. Thats what I get for righting code under stress - thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top