On Tue, 14 Dec 1999, Dick Hendrickson wrote:
> You can't detect an "end-of-file condition in a file which doesn't
> have it" because you can't create such a file. REWIND, BACKSPACE,
> OPEN, CLOSE (either explicit or implicit at program termination) all
> implicitly write an ENDFILE record to the file if the last operation
> was a data transfer output statement.
Well my statement was intended to be a bit provocative, and maybe I didn't
make myself clear, but I think I can still defend what I said.
If you take any common-or-garden text editor and create a text file (or
create a file of some compatible sort with any other piece of software)
and open it in Fortran, you have a file with no special Fortran ENDFILE
record. You can read this file using a Fortran program on any modern
platform (Linux, any other Unix, MS-DOS, Windows, VMS, etc) using any
current Fortran compiler and you will find the program detects an
end-of-file condition when it reaches the actual end of the file, i.e. it
runs out of records. So you clearly don't need an ENDFILE record to be
specially written. Neither do you need to use ENDFILE statement
explicitly when creating a file using a Fortran program. I believe,
therefore, that ENDFILE is obsolete, and that "virtual" ENDFILE records do
not actually exist.
You may choose to interpret the behaviour of some Fortran systems as if
they write a virtual ENDFILE record when doing a CLOSE operation on a file
which has been written, and that it is this virtual ENDFILE record which
triggers the end-of-file condition on re-input, but then you can believe
in Father Christmas if you wish. I can do without such beliefs, and can
write Fortran programs that do everything that I want without the ENDFILE
statement. If you think there are any current systems which have
behaviour only explicable if these ENDFILE records actually exist, I think
you need to cite chapter and verse.
--
Clive Page,
Dept of Physics & Astronomy,
University of Leicester.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|