Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 90
Accessing an Unlabeled Tape File: An Example
program does not know which write operation caused the error. Therefore this
procedure backspaces the tape to the last correctly written record and displays
it. The user then has the option of reentering the data submitted since the
displayed record or exiting the program.
The TAPE^READ^ERRORS procedure is called by READ^RECORD if an error
is encountered when a record block is read from tape. Here, the program does
not know whether the tape moved, so TAPE^READ^ERRORS reads the next
record block and examines the sequence number put on the tape when the
record was written. If the sequence number is one greater than the current
sequence number, then the tape did not move and the record just read is the
one the user wants. If the number is two greater, then the tape had moved; the
procedure discards the record just read, winds the tape back two records, and
reads again.
The code for the program follows.
?INSPECT,SYMBOLS,NOMAP,NOCODE
?NOLIST, SOURCE $TOOLS.ZTOOLD04.ZSYSTAL
?LIST
LITERAL BUFSIZE = 512;
LITERAL TBUFSIZE = 2048;
LITERAL MAXFLEN = ZSYS^VAL^LEN^FILENAME;
LITERAL ABEND = 1;
STRING .SBUFFER[0:BUFSIZE]; !Buffer for terminal I/O
INT TERMNUM; !Terminal file number
STRING .S^PTR;
INT .TBUFFER[0:(TBUFSIZE/2) - 1]; !Buffer for tape I/O
INT .LREC0 := @TBUFFER[0]; !Integer pointers to
INT .LREC1 := @TBUFFER[256]; ! records in tape
INT .LREC2 := @TBUFFER[512]; ! buffer
INT .LREC3 := @TBUFFER[768];
INT INDEX; !Index into record block
INT(32) RBLOCK; !Record block number
INT SEQ^NUM; !Record block sequence
! number
INT TAPENUM; !Tape file number
STRUCT .LOG^RECORD; !Record structure
BEGIN
STRING DATE[0:7];
INT SEQ^NUM;
STRING COMMENTS[0:501];
END;