Enscribe Programmer's Guide

9 Relative Files
Enscribe Relative Files
Enscribe relative files consist of fixed-length physical records on disk that are accessed by relative
record number. A record number is an ordinal value and corresponds directly to the record's
position in the file. The first record is identified by record number zero; succeeding records are
identified by ascending record numbers in increments of one.
Figure 20 (page 134) illustrates the structure of a relative file.
Each physical record position in a relative file occupies a fixed amount of space and each can
contain one variable-length data record (logical record). A logical record can vary in size from
zero, an empty record, to the maximum record size specified when the file was created. You can
change a record's logical length after it has been written to the file, but the lengths of all logical
records in the file must always be less than or equal to the constant size of the physical record.
Each logical record has a length attribute that can be returned when a record is read. Logical
records in a relative file can be logically deleted by issuing a write with a specified length of zero.
Once you have created the file and written a data record to it, all physical records preceding that
record are also created and actually occupy space on the disk even though they contain no data.
For example, if you create a relative file and then write a data record to record number 135,
records 0 through 134 are also physically created on the disk at that time even though they have
a logical record length of zero.
Note that this characteristic represents a limiting factor that could influence whether or not you use
the relative file type.
Figure 20 Relative File Structure
Data
Blocks
Record 0 Record 1 Record 2 Record 3
Fixed-length physical
records.
Each record position
occupies
a fixed amount of space
even
if the record contains no
data.
ataDataD
Each record has a length
attribute.
Therefore, the data portion
(logical
record) can vary within the
physical
record.
DataEmpty
Empty
The exact position where a new record is to be inserted into a relative file is specified by supplying
a record number to the FILE_SETPOSITION_ procedure. Alternatively, you can specify that records
134 Relative Files