Link to home
Start Free TrialLog in
Avatar of cntrymannj
cntrymannj

asked on

input past end of file

I am reading a text file and then based on the information in the text file I am comparing it to a sql database and then either skipping the record or writing the record to the database. However, I can not get the text file to see that it is at the end of the page. I have tried all different kinds of EOF procedures but nothing seems to work. Ever time i run the code i get the following error:

Microsoft VBScript runtime error '800a003e'
input past end of file

Here is the code, including two additional methods to attempt to get it to recognize the EOF.

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(strParm32File)
Set oTextStream = oFile.OpenAsTextStream

strReadLine = oTextStream.ReadLine
strCycleCycle = Mid(strReadLine, 19, 2)
strCycleYear = Mid(strReadLine, 22, 1)
strLDLCycle = strCycleYear & strCycleCycle

Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(strstrSUBMST0File)
Set oTextStream = oFile.OpenAsTextStream

Set objTextFile = ofso.OpenTextFile(strstrSUBMST0File, 1)
Set objFile = ofso.GetFile(strstrSUBMST0File)
Set objFile = Nothing      

'Do While objTextFile.AtEndOfStream = False
'Do While objTextFile.AtEndOfStream <> True
Do Until objTextFile.AtEndOfStream
  strReadLine = oTextStream.ReadLine
  strCheckLDL1 = Mid(strReadLine, 327, 1)
  strCheckLDL2 = Mid(strReadLine, 328, 2)
  strMatchkey = Replace(Mid(strReadLine, 4, 14),"'", "''")
  strCheckLDL = strCheckLDL1 & strCheckLDL2
  if strcomp(strCheckLDL,strLDLCycle,1)=0 then
    Set rs = execSQL("exec usp_createShadowRecord '"& strPubID &"','"& strMatchkey &"'")
  end if
Loop
oTextStream.Close

Set oTextStream = Nothing
Set oFile = Nothing
Set objTextFile = Nothing
Set oFSO = Nothing
Avatar of raj3060
raj3060
Flag of United States of America image

whenever you are reading the text stream look for end of file ascii code i.e. 26(decimal)
Compare with that to look for end of file, it might work.
give a try
--Raj
Avatar of joeposter649
joeposter649

Why are you opening the file so many times?  Get rid of the objTextFile stuff
If your reading from oTextStream then you should be checking oTextStream.AtEndOfStream
Avatar of cntrymannj

ASKER

i am only opening it one time. its doing a loop looking for the AtEndOfStream

Do Until objTextFile.AtEndOfStream
  strReadLine = oTextStream.ReadLine
  strCheckLDL1 = Mid(strReadLine, 327, 1)
  strCheckLDL2 = Mid(strReadLine, 328, 2)
  strMatchkey = Replace(Mid(strReadLine, 4, 14),"'", "''")
  strCheckLDL = strCheckLDL1 & strCheckLDL2
  if strcomp(strCheckLDL,strLDLCycle,1)=0 then
    Set rs = execSQL("exec usp_createShadowRecord '"& strPubID &"','"& strMatchkey &"'")
  end if
Loop
oTextStream.Close
ASKER CERTIFIED SOLUTION
Avatar of joeposter649
joeposter649

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
the first time it opens, it opens a seperate file.
Set oFile = oFSO.GetFile(strParm32File)
Set oTextStream = oFile.OpenAsTextStream

the second time sets a different file into the stream
Set oTextStream = oFile.OpenAsTextStream

the third one is (according to microsoft) suppose to actually open the stream and make it not loop.
Set objTextFile = ofso.OpenTextFile(strstrSUBMST0File, 1)

However when i just ran it taking out the line from microsoft, it worked perfect. That allowed it only to run the first open which sets up the first file and then the second which runs the loop.