Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 62, Input past the end of file

Status
Not open for further replies.

tincan56

MIS
Feb 18, 2002
24
US
Hi, Please help!!!!

I am trying to read in the original file with a big chunk of data (& a carriage return at the end of the last line) and write to the second file with carriage return at the end of each line. However, I am getting this Error 62, Input past the end of file.

My question is how can get rid of this error? Thank you so much for anyone's help!!!

Here is part of my code:

Open strUnparsedFilePath For Input As #1
strOutputFile = (PROCESSEDDIR & "\" & strUnparsedFileTrim & ".dat")
Open strOutputFile For Output As #2

Do While Not EOF(1)
readin133$ = Input$(133, #1)
'Print out parsed data with a carriage return
Print #2, readin133$
Loop

Close #1
Close #2
Kill (sNew)
 
Use LOF to read the length and after each input, subtract 133 from it. Before each input, make sure that the remaining chars are more than 133. Otherwise, get just the remaining Chars. [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
The error you're seeing, (Input past end of file), is safe to take for face value. The only way to rid yourself of the error is to disable error handling or modify your code so that it doesn’t read past the end of the file

You’re trying to read past the end of the file #1. You read in chunks if 133 characters at a time. Yo

Will this modification of you code work in your situation?

Private Sub Form_Load()
Dim strOutputFile As String
Dim readin133 As String

Open "c:\delete\ML05Z.txt" For Input As #1
strOutputFile = "c:\delete\ML05Z.dat"
Open strOutputFile For Output As #2

Do While Not EOF(1)
Line Input #1, readin133$
'readin133$ = Input$(133, #1)
'Print out parsed data with a carriage return
Print #2, readin133$
Loop

Close #1
Close #2

End Sub
 
Hi CCLINT, Thank you for your response. However I am still a novice when comes to programming, is it possible if you can show me what you told me with the code?

I tried to read the length with LOF, however I think I am getting the entire data length which is 1270 characters.
Since the file that I am reading from does not have carriage return EXCEPT only 1 at the end of the file.

I tried this but doesn't work - getting type mismatch error
readin133$ = Input$(133, #1)
FileLength = Loc(readin133$)
'Print out parsed data with a carriage return
Print #2, readin133$

or this:
Do While Not EOF(1)
FileLength = Loc(1) (but this is reading in 1270)

Am I missing something?

hank you so much for your help.
 
very basic(logic only - typing on the go here):

lRemainingLength = LOF(1)
lGetLength = 133

Do Until EOF(1)
If lRemainingLength < lGetLength Then lGetLength = lRemainingLength
readin133$ = Input$(lGetLength, #1)
lRemainingLength th = lRemainingLength - lGetLength

'More Code

Loop
Also, use the FreeFile function (see VB help on this) [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top