Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 104
Accessing an Unlabeled Tape File: An Example
! Prompt the user to enter additional records:
PRINT^BLANK;
SBUFFER ':='
"Do You Wish to Enter Another Record (y/n)? "
-> @S^PTR;
CALL WRITEREADX(TERMNUM,SBUFFER,@S^PTR '-' @SBUFFER,
BUFSIZE,COUNT^READ);
IF <> THEN CALL FILE^ERRORS(TERMNUM);
! Increment the index into the record block:
INDEX := INDEX + 1;
! Send record block to tape process if no more
! records, or if record block full. Flush out to tape
! every 10 writes to provide known point of consistency:
IF INDEX = 4 OR
(NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y")) THEN
BEGIN
CALL WRITEX(TAPENUM,TBUFFER,TBUFSIZE);
IF <> THEN
BEGIN
CALL FILE_GETINFO_(TAPENUM,ERROR);
IF ERROR <> 1 THEN CALL TAPE^WRITE^ERRORS(ERROR);
END;
! Increment record block sequence number and reset
! the index:
SEQ^NUM := SEQ^NUM + 1;
INDEX := 0;
! Blank tape buffer in case next record block is not
! full:
TBUFFER[0] ':=' " ";
TBUFFER[1] ':=' TBUFFER[0] FOR 1023;
! Flush to tape every 10 record blocks. Use modulo
! divide to detect tenth record. Buffered mode is
! already set, therefore SETMODE 99 forces to tape all
! records in tape buffer:
IF $DBL(SEQ^NUM) '\' 10 = 0 THEN
BEGIN
CALL SETMODE(TAPENUM,99,1);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
END;
END;
END
UNTIL NOT (SBUFFER[0] = "y" OR SBUFFER[0] = "Y");