


REWIND and BACKSPACE Statements
REWIND repositions a file to the beginning of information so that the next READ
statement will read the first record; if a WRITE statement is used after REWIND
all existing records on the file are destroyed. REWIND has no effect if the
file is already rewound. If a REWIND statement is used on a unit which is
connected but does not exist (e.g. a pre-connected output file) it creates the
file.
BACKSPACE moves the file position back by one record so that the record can be
re-read or over-written. There is no effect if the file is already positioned at the
beginning of information but it is an error to back-space a file which does not exist.
It is also illegal to back-space over records written by list-directed formatting
(because the number of records produced each time is system-dependent). A few
operating systems find it difficult to implement the BACKSPACE statement directly and
actually manage it only by rewinding the file and spacing forward to the appropriate
record. It is sometimes possible to avoid backspacing a file by allocating buffers
within the program and, for a formatted file, using an internal file READ and WRITE
statements.
These statements have similar general forms:
REWIND( control-list )
BACKSPACE( control-list )
where the control-list may contain:
UNIT=integer-expression IOSTAT=integer-variable ERR=label |
REWIND integer-expression
BACKSPACE integer-expression
where the integer expression identifies the unit number.