Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 55
Taking BREAK Ownership
This subsection is concerned with handling the BREAK key on a terminal that is
initialized and opened as an SIO file. For details on how to handle the BREAK key for
terminal files opened with regular Guardian procedure calls, refer to Section 10,
Communicating With Terminals.
Briefly, the purpose of the BREAK key is to allow the program user to signal the
process. A common example of the use of the BREAK key is to signal the TACL
process to return to command-input mode when running an application. If your
program does its own BREAK handling, however, you can cause the BREAK key to
initiate some function of your choice.
The major BREAK-handling operations with SIO procedures are outlined below and
described in detail in the paragraphs that follow.
Take BREAK ownership using the TAKE^BREAK procedure. The BREAK function
can be owned by only one process at a time. If you do not take BREAK
ownership, then the effect of pressing the BREAK key is determined by the
process that now owns the BREAK key.
Check for the pressing of the BREAK key using the CHECK^BREAK procedure.
Return BREAK ownership to the previous owner using the GIVE^BREAK
procedure. You do this when your program no longer needs to respond to the
BREAK key.
Using the SIO procedures to process the BREAK key is much simpler than using
regular Guardian procedures, because SIO hides the complexity of handling the
$RECEIVE file and checking for BREAK messages. However, use of the SIO
procedures does limit BREAK handling to one terminal per process and does not
support BREAK mode. If you need to handle the BREAK key across multiple
terminals, or if you need to make use of BREAK mode in your program, then you
should use the regular Guardian procedures as described in Section 10,
Communicating With Terminals.
Most of this subsection assumes that the $RECEIVE file is either initialized and open
as an SIO file or not open when you call CHECK^BREAK. If it is not open, then
CHECK^BREAK opens the file for you and checks for the Break message. A call to
GIVE^BREAK returns ownership of BREAK to the previous owner and closes
$RECEIVE if it was opened by CHECK^BREAK.
However, if you prefer to work with $RECEIVE in a regular Guardian environment while
handling the terminal as an SIO file, you can do so using the SET^FILE
SET^BREAKHIT operation. How to do this is described at the end of this subsection.
Taking BREAK Ownership
Use the TAKE^BREAK procedure to take ownership of the BREAK key. Doing so
allows the process to receive the Break message and respond to it. The previous
owner of BREAK will no longer receive Break messages.