FORTRAN 77 Language Reference

BACKSPACE

The BACKSPACE statement positions the specified file to just before the preceding record.

BACKSPACE u

BACKSPACE ([UNIT= ] u [, IOSTAT=ios ] [, ERR=s ])

Parameter 

Description 

u

Unit identifier of the external unit connected to the file  

ios

I/O status specifier, integer variable, or an integer array element 

s

Error specifier: s must be the label of an executable statement in the same program unit in which the BACKSPACE statement occurs. Program control is transferred to the label in case of an error during the execution of the BACKSPACE statement.

Description

BACKSPACE in a terminal file has no effect.

u must be connected for sequential access. Execution of a BACKSPACE statement on a direct-access file is not defined in the FORTRAN 77 Standard, and is unpredictable. We do not recommend using a BACKSPACE statement on a direct-access file or an append access file.

Execution of the BACKSPACE statement modifies the file position, as follows:

Prior to Execution 

After Execution 

Beginning of the file  

Remains unchanged  

Beyond the endfile record  

Before the endfile record  

Beginning of the previous record 

Start of the same record 

Examples

Example 1: Simple backspace


       BACKSPACE 2 
       LUNIT = 2 
       BACKSPACE LUNIT 

:

Example 2: Backspace with error trap:


       INTEGER CODE
       BACKSPACE ( 2, IOSTAT=CODE, ERR=9 ) 
       ... 
9      WRITE (*,*) 'Error during BACKSPACE' 
       STOP