COBOL Manual for TNS and TNS/R Programs
Disk Input and Output
HP COBOL Manual for TNS and TNS/R Programs—522555-006
28-12
Structured Files
If an HP COBOL program describes fixed-length records, any zero-length records are
discarded when read. If an HP COBOL program describes variable-length records,
upon return from the READ statement, the entire record area is undefined. For this
reason, you are advised to specify the DEPENDING phrase when reading variable-
length records, and to process zero-length records appropriately (by ignoring them, for
example).
Under Enscribe, entry-sequenced files can have alternate keys. You must create these
files by calling Enscribe directly in one of these ways:
•
From your TACL session, use FUP.
•
From within an HP COBOL program, call the FILE_CREATE_ procedure.
Topics:
•
Entry-Sequenced (Sequential) Files
•
Relative Files
•
Key-Sequenced (Indexed or Queue) Files
Entry-Sequenced (Sequential) Files
An entry-sequenced file created by an HP COBOL program is either a series of fixed-
length records or a series of variable-length records.
Your program ordinarily reads entry-sequenced files sequentially. You can read the
records in the order in which they appear in the file by opening the file for input and
reading record after record. You can append records to the file by opening the file with
an extension and writing records to the file.
Enscribe allows each physical record of an entry-sequenced file to have any length
from zero bytes (empty) to the maximum record length that was declared when the file
was created. HP COBOL allows each logical record to have any length from zero bytes
to the maximum record length declared explicitly in the file description entry or implicitly
in the record definitions following the file description entry.
If your source program describes the file as having variable-length records, each
physical record uses only as many bytes of disk space as needed; therefore, the
number of records for each block can vary according to the length of the records in
each block (although some space at the end of a block can be wasted).
If an entry-sequenced file has alternate keys, you can use a START statement to
specify the next record to read.
Relative Files
Relative files contain records that exist independent of each other. Each record is
associated with a unique relative record number—an ordinal number. The first record is
number 1, the second is number 2, and so forth. The number exists independent of the
contents of the record. You can read any record by number, but the record number is
not part of the record.