Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 2
Structured Files
Unstructured files are suitable for applications that are sequential in nature or where
the application itself provides the structure. Files created by the EDIT and TEDIT
programs are typical examples of unstructured files.
Structured Files
The Enscribe software supports the following types of structured files:
Relative files
Entry-sequenced files
Key-sequenced files
The following paragraphs describe the major characteristics of these file types and
indicate the types of applications that can best take advantage of each file type.
Relative Files
Relative files are made up of logical records. A fixed amount of storage is used for
each record, even though the data saved in the record can be a different length. The
fixed length, known as the record length, is therefore the maximum length of a relative-
file record.
Figure 5-1 shows the structure of a relative file.
Each record in a relative file is identified by a number whose value is the position of the
record in the file. The first record in the file is record number 0. You access a given
record by setting up the file pointers with the record number and then issuing the
appropriate procedure call. Existing records can be updated or deleted. An update
can change the record length (up to the maximum length). New records are usually
appended to the file.
Relative files are appropriate when you can assign unique numbers to records from a
compact range. An employee file indexed on employee number could be a suitable
application because the employee number and record number can be the same. If
there is a high turnover and employee numbers are never reassigned, however, a key-
sequenced file may be more appropriate because the relative file would contain many
empty records. A relative file also makes it impossible to include alphabetic characters
in the employee ID.
An inventory file indexed by part number might seem to be an appropriate application
of relative files. However, part-number schemes do tend to have large gaps; a record
would be reserved for each number, whether there was a corresponding part for it or
not.