Guardian Programmer's Guide

Table Of Contents
Using the IOEdit Procedures
Guardian Programmer’s Guide 421922-014
14 - 17
Line Backspacing
The following example deletes the lines between two records obtained by calls to the
GETPOSITIONEDIT procedure:
START^DELETE := GETPOSITIONEDIT(FILE^NUM);
.
.
END^DELETE := GETPOSITIONEDIT(FILE^NUM):
ERROR := DELETEEDIT(FILE^NUM,START^DELETE,END^DELETE);
IF ERROR > 0 THEN ...
Line Backspacing
The BACKSPACEEDIT procedure performs the equivalent of a FORTRAN
BACKSPACE statement on the file.
The purpose of the BACKSPACEEDIT procedure is as follows. The ANSI FORTRAN
standard specifies that the ENDFILE statement writes an end-of-file record and that a
BACKSPACE statement backspaces over that record if it follows an ENDFILE
statement or a READ statement that returned the end-of-file status. The EDIT file
format does not provide an end-of-file marker; the logical end-of-file is immediately
after the highest-numbered line in the file.
To satisfy the ANSI requirement, the FORTRAN ENDFILE statement and READ
end-of-file will both set the file’s current record number to -2, indicating that a simulated
end-of-file record has just been read or written; in this case, the BACKSPACEEDIT
procedure clears the end-of-file status indication by setting the current record number
to that of the highest-numbered line in the file. Table 14-5 summarizes the effect of the
BACKSPACEEDIT procedure:
The procedure call takes the EDIT file number as its only parameter and returns a
file-system error code:
ERROR := BACKSPACEEDIT(FILE^NUM);
IF ERROR > 0 THEN ...
Table 14-5. Effects of the BACKSPACEEDIT Procedure
If the current record number is... Then the BACKSPACEEDIT Procedure...
-1 Does nothing
-2 Sets the current record number to the highest-
n
umbered record in the file, or to -1 if the file is empty
Greater than or equal to 0 Sets the current record number to the number of the
p
receding record in the file, or to -1 if no such record
exists