?
Solved

input past end of file

Posted on 2004-09-07
5
Medium Priority
?
388 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 250 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

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

719 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