Guardian Programmer's Guide

Table Of Contents
Communicating With Magnetic Tape
Guardian Programmer’s Guide 421922-014
12 - 105
Accessing an Unlabeled Tape File: An Example
! Write EOF marks to end of tape:
CALL CONTROL(TAPENUM,2);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
CALL CONTROL(TAPENUM,2);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
END;
!------------------------------------------------------------
! Procedure to initialize a scratch tape with two EOF marks.
!------------------------------------------------------------
PROC SCRATCH^TAPE;
BEGIN
! Make sure tape is at BOT. Because this may be the first
! access to tape, check for error 100. If detected, call
! FILE^ERRORS to prompt user to fix the problem, then retry:
CALL LOAD^TAPE;
! Write two EOF marks to tape:
CALL CONTROL(TAPENUM,2);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
CALL CONTROL(TAPENUM,2);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
! Rewind to BOT ready for writing records.
CALL CONTROL(TAPENUM,6);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
END;
!------------------------------------------------------------
! Procedure to stop the program on request. As well as
! stopping the program, this procedure rewinds and unloads
! the tape.
!------------------------------------------------------------
PROC EXIT^PROGRAM;
BEGIN
! Rewind and unload the tape:
CALL CONTROL(TAPENUM,3);
IF <> THEN CALL FILE^ERRORS(TAPENUM);
! Stop the program:
CALL PROCESS_STOP_;
END;