The backspace statement will position an external file before the preceding record in that file. However, this statement will only work on files that have been connected for sequential access only.
The backspace statement will support only three specifiers. They are as follows:
This specifier identifies the file that the programmer wishes to have the backspace operation preformed on. This, with the unit number of the file, or just the unit number by itself must always appear in the backspace statement.
This specifier is not mandatory in the backspace statement. However, when used, it will store an integer value in a variable that is placed after the equal sign. The integer value that gets stored provides information on the status of the backspace operation. If there where no problems with the backspace operation, then a value of zero is stored in the variable. If an error occurred while attempting to preform the operation, then a positive integer value will get stored inside the variable.
This is another optional specifier with the backspace argument. A statement label is referenced after the equals sign of the specifier. The program will branch to that statement if an error occurs while attempting the backspace operation.
The backspace statement is normally used with only a unit specifier as in the following, which moves the position pointer back one record in the file attached to unit 12.
If it might be necessary to include the iostat and err arguments, the backspace statement would appear like this.
Of course, a statement 100 would have to appear in the program later on and it would also be wise to include a print or write statement to display the error condition if it occurs.
lecture twenty two
example: backspace.f , noadv.f.
Written by Jason Wehr : email@example.com and Maintained by John Mahaffy : firstname.lastname@example.org