Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 58
Handling BREAK Ownership: An Example
!------------------------------------------------------------
!Procedure called when CHECK^BREAK detects BREAK. It prompts
!the user for some input and then writes the input to the
!output file.
!------------------------------------------------------------
PROC BREAK^PRESSED;
BEGIN
INT .BUFFER[0:127],
BYTES^READ;
CALL READ^FILE(INFILE,BUFFER,BYTES^READ);
CALL WRITE^FILE(OUTFILE,BUFFER,BYTES^READ);
IF BUFFER = "exit" THEN
BEGIN
CALL GIVE^BREAK(INFILE);
CALL CLOSE^FILE(COMMON^FCB);
CALL PROCESS_STOP_;
END;
END;
!------------------------------------------------------------
!Main procedure initializes and opens files, then loops while
!waiting for the BREAK key. When the BREAK key is pressed,
!it calls the BREAK^PRESSED procedure.
!------------------------------------------------------------
PROC TERMS MAIN;
BEGIN
INT STATE,I,J;
?IF PTAL !Begin pTAL statements
LITERAL NUM^FCBS = 2;
WADDR FCB^ARRAY[0:NUM^FCBS-1];
! Initialize the terminal file:
FCB^ARRAY[0] := @INFILE;
FCB^ARRAY[1] := @OUTFILE;
CALL INITIALIZER(CONTROL^BLOCK,,,,,,,NUM^FCBS,FCB^ARRAY);
?ENDIF PTAL !End pTAL statements
?IFNOT PTAL !Begin TAL statement
CALL INITIALIZER(CONTROL^BLOCK);
?ENDIF TAL !End TAL statement
! Assign read/write access to the input file. This file
! will be used as the terminal file:
CALL SET^FILE(INFILE,ASSIGN^OPENACCESS,
READWRITE^ACCESS);
! Assign read/write access to the output file. This file
! will be used as the $RECEIVE file:
CALL SET^FILE(OUTFILE,ASSIGN^OPENACCESS,READWRITE^ACCESS);