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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

EOF missing

Status
Not open for further replies.

DugzDMan

Programmer
Oct 19, 2000
157
US
I have a program that reads a file downloaded from our mainframe. Before I can read it in as text, I open it in Binary mode and clean the non-ASCII characters and save it to a new name (so the user can run the clean file the next time and not have to wait until the file is cleaned again). The problem is that once the file is cleaned, it no longer has the end of file marker. Can some one tell me how to add that to the end of the file? I am writing the clean file by using the Print #2, ... method.
 
The close #2 after you are finished writing the file should take care of the EOF. You do have a close statement, right?

 
I am using Close, that's why I'm stumped.

If it makes any difference, I'm using VB6 SP5 on Win2K SP2.

Thanks!
 
When I read the file in, I get the Input past end of file error.
 
What mode are you opening file #2 (the output) in? Should be open for output. You have to supply EOF in binary.

Short of that, I would check the routine you are using to import the file the second time.
 
I'm thinking it must be somewhere with the names I am using while manipulating the files (open file, clean, write to temp file while processing, close files, rename temp file as clean file, open clean file to process, etc.).

I have to get to work early, so I'm going to look at it tomorrrow. I'm sure it will probably jump out at me if I take a break.

Thanks for the help!
 
Just as a reminder, "binary" will replace the individual byte you tell it to, including the EOF. By using binary, the file size is maintained and not augmented.

So if the file is 3 bytes (ex: HI{eof}) and you tell it to replace byte number 3 with "T" (ex: HIT) then the headackes start.

My suggestion(s);

1.) If you have the source code, is to run some test data and when the EOF of #2 is reached STOP/BREAKPOINT and see (in debug window) the last character posted and position (use the SEEK function).

If you know this to be the actual culprit, modify your code and add after the loop, BackIn=LOF(#2)-1: seek #2, backln: print #2, ^z: close #2

2.) Change the output file to "append" or "output" instead of binary so that the eof is automatically added and file size (which WILL INCLUDE the eof mark) will be changed. But this may not be what you may want to do.

--MiggyD
 
If your input statement contains more variables than the file contains you will get the same error. You are not missing the EOF.

Input #2, TPT, TPP, TPF, PTH, PTL, PFR, AVF, TAF

If the file only contains 6 entries you will get the error.

file contents:

34,12,23,445,12,123

 
I believe I was making an elementary mistake. I haven't had time to go through all the code again to make sure, but I think I was referencing the wrong file (one that contains the same type of data, but more lines). I hope to get back to this early this week.

Thanks for all the help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top