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!

Error-Input Past end of file

Status
Not open for further replies.

twix79

IS-IT--Management
Apr 5, 2002
110
US
I have an application in which three programs share some files. Each program checks one particular file to see if it is set as a one or a zero. A one says that other files are in use, while a zero says that they are free. The program then sets the file back to a zero after it is done. I received a run-time error stating: Input past end of file. My hunch here is that one program attempted to read an empty file. This would only seem likely to happen if the program had attempted to read from a file that had been read by another file, but had not yet been updated with a zero. Here is the code that I use when checking the file:

Open MWIFile_In_Use For Input As #MWIFile_In_UseFB 'Sets
flag bit to unbusy
Lock #MWIFile_In_UseFB
Read #MWIFile_In_UseFB, MWIFuseStatus
Unlock #MWIFile_In_UseFB
Close

This is the code that I use when setting the file back to zero:

Open MWIFile_In_Use For Output As #MWIFile_In_UseFB 'Sets
flag bit to unbusy
Lock #MWIFile_In_UseFB
Write #MWIFile_In_UseFB, 0
Unlock #MWIFile_In_UseFB
Close

I'm curious as to how likely it is that one program happened to access the file during the brief instant that another program did not have control of it. I have been running these programs with a fairly steady stream of data 24/7 for about 35 days and just had the first error.

I do realize that using a database would have been a better approach for this issue, but I would prefer to stick with my current programs if this is not an error that will be common. An incident once every month or two is probably acceptable.

Any thoughts?

Thank you,
Jesse
 
It is very unlikely, which is why it happens. Years ago I had some code in assembler on a flight sim. It was basically

set light off
if switch on skip next instruction
set light on

The light flashed on and off like a metronome. Quite amazing.

I think what you need to do is to check whether the file is already open and if it is wait a bit and try again. etc Peter Meachem
peter@accuflight.com

Support Joanna's Bikeathon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top