Guardian Programmer's Guide

Table Of Contents
Communicating With Disk Files
Guardian Programmer’s Guide 421922-014
5 - 72
Using Alternate Keys With an Entry-Sequenced File
Using Alternate Keys With an Entry-Sequenced File
The application of alternate keys to an entry-sequenced file is similar to applying
alternate keys to relative files. Instead of a record number, the alternate-key file cross-
references the alternate-key value to a record address.
Applying alternate keys to the example given in the subsection Using Entry-Sequenced
Files produces the structure shown in Figure 5-6:
You can enhance the sample program shown in the subsection Using Entry-
Sequenced Files to use the date as an alternate key by making exactly the same
changes as were made to the relative-file example.
Using Alternate Keys With a Key-Sequenced File
When using alternate keys with a key-sequenced file, the alternate key cross-
references the primary key.
For an example of how to use alternate keys with a key-sequenced file, the example
given in the subsection
Using Key-Sequenced Files is modified to be able to read
records using the part description as a key. The alternate-key file therefore lists
r
ecords in part-description order, each referencing a part number. Figure 5-7 shows
the sample file structure.
Figure 5-6. Example of Alternate-Key File for Use With an Entry-Sequenced File
VST030.VSD
Alternate-Key File
Data File
DA 19890102 2050
DA 19890109 2049
DA 19890106 04
DA 19890105 03
DA 19890104 2048
DA 19890104 02
DA 19890103 01
DA 19890102 00
19890102
19890103
19890102
19890109
19890104
19890106
19890105
19890104
00
01
02
03
04
2048
2049
2050
Key Specifier
Secondary Key
Primary Key
Record Number
Secondary Key (Date)
Comments