Solved

input past end of file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Problem to be resolved in this article Currently, development of website and web application can be done without writing thousands of lines of programming code by hand. Description This can be done through by using a open source framework such …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

910 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

22 Experts available now in Live!

Get 1:1 Help Now