Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 102
Accessing an Unlabeled Tape File: An Example
!------------------------------------------------------------
! Procedure to append a record to the file.
!------------------------------------------------------------
PROC APPEND^RECORD;
BEGIN
INT ERROR;
INT COUNT^READ;
! Rewind tape and position the tape to EOF. Since this might
! be the first access to tape, check whether the tape is
! ready by checking for error 100. If error 100 detected,
! call FILE^ERRORS to prompt the user to fix the problem,
! then retry the operation:
CALL LOAD^TAPE;
! Position the tape to EOF:
CALL CONTROL(TAPENUM,7,1);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
CALL CONTROL(TAPENUM,8,1);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
! Space back one record and establish sequence number of
! last record written to tape:
CALL CONTROL(TAPENUM,10,1);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(TAPENUM,ERROR);
IF ERROR = 154
THEN SEQ^NUM := 0
ELSE CALL FILE^ERRORS(TAPENUM);
END
ELSE
BEGIN
CALL READX(TAPENUM,TBUFFER,TBUFSIZE);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
LOG^RECORD ':=' TBUFFER[0] FOR 512;
SEQ^NUM := LOG^RECORD.SEQ^NUM + 1;
END;
! Blank tape buffer:
TBUFFER[0] ':=' " ";
TBUFFER[1] ':=' TBUFFER[0] FOR 1023;
! Initialize the index into the tape buffer:
INDEX := 0;