[comp.os.vms] Curious as to how Fortran BACKSPACE works

gr47@sdcc12.ucsd.EDU (gr47) (05/18/88)

I am curious as to how Fortran BACKSPACE works.  I vaguely remember
reading in one of the orange manuals that BACKSPACE simply causes
the logical unit to be rewound and read from THE BEGINNING forward to
the record immediately preceding the current one.  Is this true?
How are huge time delays avoided when BACKSPACE'ing large files, or
are delays not avoided?  Or do I remember wrong, and does BACKSPACE
use the saved (?) position of the start of the previous record to do
its task?

My curiosity resulted from looking over AStine's recent attempt at a
TAIL Fortran program.  He tried to useropen a file at the EOF, then
backspace from there, apparently without success.
It would have been nice...

I'd be interested in all commments.

Steve Piper
scpiper@ucsd
scpiper@ucsd.bitnet
cdrgmv::piper2       ! span

LEICHTER@VENUS.YCC.YALE.EDU ("Jerry Leichter ", LEICHTER-JERRY@CS.YALE.EDU) (05/22/88)

	I am curious as to how Fortran BACKSPACE works.  I vaguely remember
	reading in one of the orange manuals that BACKSPACE simply causes the
	logical unit to be rewound and read from THE BEGINNING forward to the
	record immediately preceding the current one.  Is this true?  How are
	huge time delays avoided when BACKSPACE'ing large files, or are delays
	not avoided?  Or do I remember wrong, and does BACKSPACE use the saved
	(?) position of the start of the previous record to do its task?

As I understand it, the implementation does the second most obvious thing (the
obvious thing being to simply read again from the beginning of the file):  As
you read forward, the FORTRAN I/O system keeps a record of where the records
it sees occur (by storing RFA's).  It can then backspace by just seeking.
Obviously, it can't store an indefinite number of RFA's, but by being a bit
clever (say, always keep a the last 50 RFA's, then every RFA in steps of 50
before that for some fixed number of records, with an ultimate fallback to
seeking back to the beginning of the file) it can handle most BACKSPACE
requests - which are usually for only a couple of records - quite efficiently
using only a small amount of space.
							-- Jerry