COBOL Manual for TNS and TNS/R Programs
Data Division
HP COBOL Manual for TNS and TNS/R Programs—522555-006
7-20
File Description Entries
Usage Considerations:
•
Describing Fixed-Length Records
The RECORD CONTAINS length-fixed CHARACTERS form specifies that the
file consists of fixed-length records. Both other forms specify that the file consists
of variable-length records.
If the record you write is smaller than the fixed length, the extra characters are
undefined.
If you declare a file for a terminal, you must specify variable-length records, or else
each record entered must be exactly the same length.
•
Defaulting to Fixed-Length Records
If no RECORD clause is present, the compiler declares the file to consist of fixed-
length records. In this case, the record length is the size of the associated record
description entry specifying the greatest number of character positions.
•
File With Fixed-Length Records Can Hold Records of Shorter Lengths
If you describe a file as having fixed-length records, each record description for
that file’s record area can describe a record of any length from 1 up to the stated
fixed length.
The length you specify in the RECORD CONTAINS clause is the fixed length of the
record area that holds individual records read from or to be written to the file during
execution. Each record description entry can define the record area in a different
way, possibly describing a record of a shorter length than the actual record has in
the record area or in the file.
•
Example of a File with Fixed-Length Records
This explicitly declares a file to have fixed-length records:
RECORD CONTAINS 256 CHARACTERS
•
Purpose of Variable-Length Records
If you describe a file as having variable-length records, the individual record
descriptions for that file can be of any length from the stated or implied minimum
length to the stated or implied maximum length. The specified minimum size can
be less than that implied by the record description entry defining the smallest
number of character positions. The specified maximum size can be greater than
that implied by the record description entry defining the largest number of
character positions; however, only those character positions defined in the record
descriptions are accessible to the program.
If the record you write is smaller than the minimum length, the extra characters are
undefined.