Accessing Files Programmer's Guide (32650-90885)

60 Chapter2
Creating A File
Specifying a File Type
files may not be simultaneously accessed by both readers and writers. When the file has
been closed by all writers, it may be read; a reader takes records from the circular file one
at a time, starting at the head of the file.
Circular files are particularly useful as history files, when a user is interested in the
information recently written to the file and is less concerned about earlier material that
has been deleted. These history files are frequently used as debugging tools. Diagnostic
information may be written to the file, and the most recent and relevant material can be
saved and studied.
Creating a circular file is similar to creating a message file. When a user process opens a
new file and indicates that it will be a circular file, the HPFOPEN/FOPEN intrinsic creates the
new circular file. In order to create a circular file with the BUILD command, use the CIR
keyword; for example, to build a circular file named CIRCLE, enter:
BUILD CIRCLE;CIR
A new circular file may also be specified with a FILE command. Use the CIR keyword for a
new file:
FILE ROUND, NEW; CIR
A circular file named ROUND is indicated.
When you perform a LISTFILE,2 command, circular files are identified by an "O" in the
TYP field; CIRCLE is identified here:
FILENAME CODE -----------LOGICAL RECORD----------- ----SPACE----
SIZE TYP EOF LIMIT R/B SECTORS #X MX
CIRCLE 256B FBO 0 1023 1 0 0 8
Message files
Message files are used by interprocess communication (IPC), a facility of the file system
that permits multiple-user processes to communicate with one another in an easy and
efficient manner. Message files act as first-in-first-out queues of records, with an entry
made by FWRITE and a deletion made by FREAD; one process may submit records to the file
with the FWRITE intrinsic while another process takes records from the file using the FREAD
intrinsic.
Message files are not dealt with in this manual. Instead, the creation and application of
message files are discussed in great detail in the IPC Communication Programmer's
Guide.