Guardian Programmer's Guide

Table Of Contents
Using the File System
Guardian Programmer’s Guide 421922-014
2 - 23
Following the above call, the current-record and next-record pointers are positioned as
follows:
Successive write operations then append records to the file.
I/O With Devices
Sections 9 through 12 describe I/O operations to device files in detail. This subsection
briefly presents the procedures used and gives one specific example of the
WRITEREADX procedure that is particularly useful for communicating with terminals.
Because devices can be treated as files, input and output to devices can be done
using read and write operations like those for disk files. For device-specific operations,
such as setting the mode of operation for a device, you use the SETMODE and
CONTROL procedures.
Writing to a printer involves simply using the WRITE[X] procedure. Communicating
with magnetic tape uses the READ[X] and WRITE[X] procedures along with the
CONTROL procedure that is used to space the tape backwards and forwards. I/O to
terminals can also be done using simple READ[X] and WRITE[X] calls. In many
applications, however, communicating with a terminal involves displaying a prompt and
then waiting for a response. The WRITEREAD[X] procedure combines both of these
operations into one procedure.
The WRITEREAD[X] procedure has two parts: the first part writes the contents of a
m
emory buffer to the specified file, and the second reads the response back into the
same buffer. The procedure requires at least four parameters: the file number of the
file you want to communicate with, the buffer name, the number of bytes to be written,
and the maximum number of bytes that will be returned. When communicating with a
terminal in conversational mode, the read ends when a line-termination character is
entered (typically a carriage return). A fifth parameter returns the actual number of
bytes read.
The following example prompts the user to enter an account number. The procedure
r
eturns when the user has entered a number and pressed the line-termination
character:
VST015.VSD