From: Ron Shepard on
In article <4b70e76b$0$1785$afc38c87(a)news.optusnet.com.au>,
"John Paine" <johnpaine1(a)optusnet.com.au> wrote:

> >> open(unit,...position='append'...)
> >> rewind unit
> > I bet you mean "backspace unit"
> >
> > I also wondered why the OP didn't do this.

Yes, the example should have been

open(unit,...position='append'...)
backspace unit
read(unit) last_info

>
>[...]
> Some of the files can be quite large, so reading to the end to
> find the defining header record seems somehow wrong to me.[...]

My example was not clear because of my mistake of using rewind
rather than backspace. As you can see, this does not read through
the entire file.

$.02 -Ron Shepard
From: glen herrmannsfeldt on
John Paine <johnpaine1(a)optusnet.com.au> wrote:
(snip)

> From comments by other posters, I gather that some of the basic tenets of
> file access are still grounded in the exigencies of reading tapes, and in
> that context truncate after write presumably makes perfect sense (though I'm
> sure that there was a way to rewrite records on tape too, but it may have
> involved using an assembler routine to stop the tape writing the EOF
> marker). However it's been a long time since I or anyone I work for have
> used tape units as part of a data processing stream, so being able to
> rewrite a portion of a file without truncating the file seems to me to be a
> perfectly reasonable thing to do and something the computer itself is also
> perfectly capable of performing. My failure was that I have lagged badly in
> keeping up with changes in the language and knew nothing about stream files.
> Thankfully the newsgroup is alive and well and put me on the right path very
> quickly.

The reason is more complicated than that. The format of data on disks,
including gaps between blocks, is carefully designed such that one can
fully overwrite a block, yet not write over the beginning of the
following block. There have been tape systems that did that, but
many did not. DECtape, a tape system used by many early DEC computer,
was designed that way. That is, as a direct access tape system.

Disk low level formats have a block header with the address
(cylinder, track, sector) for that block positioned such that the
header can be read and then, at just the right time, the new
data written. As the disk speed may vary with time or between
drives, the size of the gap following a data block is very
important. The drive must write 'idle' data long enough to
overwrite the end of a block previously written at the high end
of the speed tolerance, while now writing at the low end.

-- glen