Guardian Programmer's Guide

Table Of Contents
Using the Sequential Input/Output Procedures
Guardian Programmer’s Guide 421922-014
15 - 57
Handling BREAK Ownership: An Example
procedure with the FCB name for the terminal from which you were accepting BREAK
ownership:
CALL GIVE^BREAK(TERM^FCB);
Handling BREAK Ownership: An Example
The following example responds to the BREAK key pressed at the terminal designated
as the input file in the Startup message. Under normal operation, the process
executes without interacting with the user. However, the process does periodically
check for the BREAK key by issuing a CHECK^BREAK procedure call within the main
loop of the program. If the process receives the Break message, then it calls the
BREAK^PRESSED procedure. If no Break message is received, the process carries
on executing.
The BREAK^PRESSED procedure first prompts the user for input. It then sends the
users response to the file designated as the output file in the Startup message. This
procedure also provides the user with the opportunity to exit the program by typing
“exit.”
Note that this example includes both the native (pTAL) and TNS (TAL) forms of the
INITIALIZER call. Conditional compilation directives are included to select the
appropriate form so that the example will execute in either environment. Alternatively,
the native form of the INITIALIZER call will work in a TNS procedure, but some
additional setup is required. See Using the INITIALIZER Procedure, earlier in this
section, for more information on calling the INITIALIZER procedure.
?INSPECT, SYMBOLS
!Source in the GPLDEFS file:
?NOLIST, SOURCE $SYSTEM.SYSTEM.GPLDEFS
?LIST
!Allocate the RUCB:
ALLOCATE^CBS(CONTROL^BLOCK,COMMON^FCB,2);
!Allocate FCBs for the input and output files:
ALLOCATE^FCB(INFILE," #IN ");
ALLOCATE^FCB(OUTFILE," #OUT ");
!Source in the system procedures including the SIO
!procedures.
?NOLIST
?SOURCE $SYSTEM.SYSTEM.EXTDECS0(DEBUG,INITIALIZER,
? OPEN^FILE,READ^FILE,WRITE^FILE,TAKE^BREAK,
? CHECK^BREAK,SET^FILE,CLOSE^FILE,
? PROCESS_STOP_)
?LIST
?NOMAP,NOCODE