Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 59
Handling BREAK Ownership With $RECEIVE
Handled as a Non-SIO File
! Open the input file:
CALL OPEN^FILE(COMMON^FCB,INFILE);
! Open the output file:
CALL OPEN^FILE(COMMON^FCB,OUTFILE);
! Take ownership of the BREAK key pressed at the terminal:
CALL TAKE^BREAK(INFILE);
! Loop indefinitely:
WHILE 1 = 1 DO
BEGIN
! Check whether the BREAK key has been pressed. If so,
! call BREAK^PRESSED:
STATE := CHECK^BREAK(INFILE);
IF STATE = 1 THEN CALL BREAK^PRESSED;
! Main body of code. Executes repeatedly until BREAK
! key is pressed:
J := 0;
WHILE J < 2000 DO
BEGIN
I := 0;
WHILE I < 2000 DO
I := I + 1;
J := J + 1;
END;
END;
END;
Handling BREAK Ownership With $RECEIVE Handled as a
Non-SIO File
So far, it has been assumed that the $RECEIVE file and the terminal file are both
opened as SIO files. However, you can open the terminal file as an SIO file while
having $RECEIVE accessed by regular Guardian procedure calls.
Because the terminal file is opened as an SIO file, TAKE^BREAK and GIVE^BREAK
operate as already described. CHECK^BREAK, however, does not work because it
needs $RECEIVE opened as an SIO file. You therefore need to check for the Break
message by reading messages from $RECEIVE directly.
When your program receives a Break message, you can inform the SIO environment
by using the SET^BREAKHIT operation of the SET^FILE procedure:
CALL SET^FILE(COMMON^FCB,
SET^BREAKHIT);