Accessing Files Programmer's Guide (32650-90885)

Chapter 2 59
Creating A File
Specifying a File Type
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 and Using
KSAM/XL.
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