Guardian Programmer's Guide

Table Of Contents
Using the File System
Guardian Programmer’s Guide 421922-014
2 - 18
Reading and Writing Data
!nowait^depth!,
RECEIVE^DEPTH);
The requester process can now pass messages to the server process.
Reading and Writing Data
The operating system supports several procedure calls that enable reading and writing
of files:
READX and READ each read a record from an open file into an application buffer.
There are two differences between these procedures: one is that READX can read
into a buffer in either the user data segment or an extended data segment,
whereas READ must have the application buffer in the user data segment; the
other difference is that READX reads data into a buffer declared with data type
STRING, whereas READ reads data into a buffer declared with data type INT.
WRITEX and WRITE each write a record to an open file from an application buffer.
The same two differences apply to WRITE and WRITEX as to READ and READX,
this time regarding the position and data type of the buffer containing the data to be
written.
See Section 17, Managing Memory, for discussions on accessing extended data
segments.
Before performing any I/O to a file, the file must be open as described in Opening
Files, earlier in this section.
I/O With Disks
I/O to all supported types of disk files is described in detail in Section 5,
Communicating With Disk Files. This subsection describes some of the simple
operations that can be performed on unstructured files. The various pointers used to
control position within the file and the procedures used to perform I/O operations are
introduced.
Associated with each file that you have open are three pointers: a current-record
po
inter, a next-record pointer, and an end-of-file pointer. The current-record pointer
and next-record pointer are used to establish at which byte in the file a read or write
operation will begin. These pointers can be manipulated to perform sequential or
random access.
The end-of-file pointer simply points to the last relative byte of the file plus 1. It is
au
tomatically advanced by the number of bytes written whenever you append data to
the file.