Solved

input past end of file

Posted on 2004-09-07
5
365 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Read about why website design really matters in today's demanding market.
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmakerā€¦
The viewer will learn how to dynamically set the form action using jQuery.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now