Solved

input past end of file

Posted on 2004-09-07
5
377 Views
Last Modified: 2012-06-27
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
0
Comment
Question by:cntrymannj
  • 2
  • 2
5 Comments
 
LVL 11

Expert Comment

by:raj3060
ID: 11999212
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
0
 
LVL 15

Expert Comment

by:joeposter649
ID: 11999330
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
0
 

Author Comment

by:cntrymannj
ID: 11999406
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
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 125 total points
ID: 11999538
I count 3 times...
Set oTextStream = oFile.OpenAsTextStream
Set oTextStream = oFile.OpenAsTextStream
Set objTextFile = ofso.OpenTextFile(strstrSUBMST0File, 1)

Try something like this...
Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFile = oFSO.GetFile(strParm32File)
Set oTextStream = oFile.OpenAsTextStream
'Do While oTextStream.AtEndOfStream <> True
  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
et oFile = Nothing
et oFSO = Nothing
0
 

Author Comment

by:cntrymannj
ID: 12000169
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.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question