Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 96
Accessing an Unlabeled Tape File: An Example
BEGIN
PRINT^STR("Read error: Unable to Verify sequence.");
SBUFFER ':=' "Do You Wish to Continue? (y/n) "
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
IF NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y") THEN
CALL PROCESS_STOP_;
END;
END;
!------------------------------------------------------------
! Procedure for responding to errors incurred when writing to
! magnetic tape. Because the program uses buffered mode, the
! program does not know which records have been written to
! tape. This procedure therefore backspaces the tape to the
! last record block that was correctly written to tape,
! then prompts the user to reenter missing messages.
!------------------------------------------------------------
PROC TAPE^WRITE^ERRORS(ERR^NO);
INT ERR^NO;
BEGIN
INT COUNT^READ;
! Set up the buffer and display error number on terminal:
START^LINE;
PUT^STR
("Tape Write Error: File System Error Number is: ");
PUT^INT (ERR^NO);
CALL WRITEX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER);
! Space the tape backward one record:
CALL CONTROL(TAPENUM,10,1);
! Read the record. If the read returns an error, space back
! to the previous record and read that one. If that read
! returns an error, call FILE^ERRORS and stop the program:
CALL READX(TAPENUM,TBUFFER,TBUFSIZE);
IF <> THEN
BEGIN
CALL CONTROL(TAPENUM,10,2);
CALL READX(TAPENUM,TBUFFER,TBUFSIZE);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
! Get the last record in the retrieved record block:
LOG^RECORD[0] ':=' LREC3[0] FOR 256;