Guardian Programmer's Guide

Table Of Contents
Using the File System
Guardian Programmer’s Guide 421922-014
2 - 30
Accessing Files: An Example
The INIT procedure reads and discards the Startup messages before opening the
terminal file and the disk file containing the daily log.
The GET^COMMAND procedure displays a menu of options on the user’s terminal
and returns the selected option (“r,” “a,” or “x”) to the main procedure.
The READ^RECORD procedure reads records from the log file. Starting from the
beginning of the file, this procedure reads each record from the file, displays it on
the terminal, and then prompts the user to read the next record. If the user
declines or the end of the file is reached, the procedure returns to the main
procedure.
The APPEND^RECORD procedure prompts the user to enter some comments and
then writes those comments to the end of the file.
The EXIT^PROGRAM procedure stops the program.
The ILLEGAL^COMMAND procedure responds to the user entering an illegal
function. That is, the user entered something other than “r,” “R,” “a,” “A,” “x,or “X.”
After informing the user of the illegal input, the procedure returns to the main
procedure.
The FILE^ERRORS^NAME and FILE^ERRORS procedures display error
messages when the program receives a file-system error on trying to execute a
file-system procedure call. FILE^ERRORS^NAME is used if the file is not yet
open. FILE^ERRORS is used if the file is already open. After displaying a file-
system error message, these procedures stop the process.
The TAL code for this program appears on the following pages.
Note. Near the beginning of the source code that follows are some definitions of TAL
DEFINEs used by the program to help formatting and displaying messages. Refer to the TAL
Reference Manual for details of TAL DEFINEs. Do not confuse TAL DEFINEs with the file
system DEFINEs described in Section
7, Using DEFINEs.