HP 3000 Manuals

Specifying a File Type [ Accessing Files Programmer's Guide ] MPE/iX 5.0 Documentation


Accessing Files Programmer's Guide

Specifying a File Type 

When you create, a file the file system imposes a structure and access
method on the contents of the file.  The file system allows you to access
the records in a file only in the manner dictated by the file type that
you specified at file creation.  Depending upon your intended use of the
file, you can specify four special file types in addition to the standard
file type:  KSAM files, RIO files, circular files, and message files.

Standard files 

By far the most common type of file is the standard file, a structure
comprised simply of a group of records beginning with record 0 and ending
with record n - 1 (where n is the maximum specified in the filesize 
option).  Examples of standard files are Editor files and program files.
A standard file is the default file type created when you first open a
file.

KSAM files 

The keyed sequential access method (KSAM) is a method of organizing
records in a file according to the content of key fields within each
record.  Every record in a KSAM file contains a primary key field whose
contents determine the primary logical sequence of records in the file.
Other key fields can also be defined so that the file can be sequenced in
alternate orders.  The order in that the records are physically written
to the file, the chronological order, can be the same as the primary key
sequence or it can be unrelated to any logical sequence.

KSAM files are not dealt with in this manual.  Instead, the creation and
application of KSAM files are discussed in great detail in the KSAM/3000 
Reference Manual (30000-90079).

RIO files 

RIO is a random access method that permits individual file records to be
deactivated.  These inactive records retain their relative position
within the file.  RIO files are intended for use primarily by COBOL
programs; however, you can access these files by programs written in any
language.

RIO files may be accessed in two ways:  RIO access and non-RIO access.
RIO access ignores the inactive records when the file is read
sequentially using the FREAD intrinsic, and these records are transparent
to you; however, they can be read by random access using FREADDIR. They
may be overwritten both serially and randomly using FWRITE, FWRITEDIR, or
FUPDATE. With RIO access, the internal structure of RIO blocks is
transparent.

Circular files 

Circular files are wrap-around structures that behave as standard
sequential files until they are full.  As records are written to a
circular file, they are appended to the tail of the file; when the file
is filled, the next record added causes the block at the head of the file
to be deleted and all other blocks to be logically shifted toward the
head of the file.  Circular 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
Interprocess Communication Programmer's Guide (32650-90019).



MPE/iX 5.0 Documentation