Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 95
Accessing an Unlabeled Tape File: An Example
!------------------------------------------------------------
! Procedure for responding to errors incurred while reading
! from magnetic tape. This procedure tries the read again. If
! sequence numbers are inconsistent, then a read was skipped
! due to the error. The procedure compensates by backspacing
! over two records.
!------------------------------------------------------------
PROC TAPE^READ^ERRORS(ERR^NO);
INT ERR^NO;
BEGIN
INT COUNT^READ;
! Set up the buffer and display error number on terminal:
PUT^STR
("Tape Read Error: File System Error Number Is: ");
PUT^INT(ERR^NO);
CALL WRITEX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Reissue the read call:
CALL READX(TAPENUM,TBUFFER,TBUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Extract a record:
LOG^RECORD[0] ':=' TBUFFER[0] FOR 256;
! Check the sequence number. If it is one greater than
! the current sequence number, then the program has read the
! intended record. If it is two greater, then the program
! skipped a record block on account of the error. In this
! case, the procedure backspaces two records and then reads
! again. If the sequence number is neither one nor two
! greater, then the program cannot establish the correct
! record by this means (this will happen, for example, if
! an error occurs during the first read after positioning
! the tape).
IF LOG^RECORD.SEQ^NUM = (SEQ^NUM +1) THEN
BEGIN
END
ELSE IF LOG^RECORD.SEQ^NUM = (SEQ^NUM + 2)
THEN
!Do nothing
BEGIN
CALL CONTROL(TAPENUM,10,2);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
CALL READX(TAPENUM,TBUFFER,TBUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
END
ELSE