## 12.6.25 RECL Specifier

The RECL specifier indicates the length of each record in a file connected for direct or keyed access, or the maximum length of a record in a file connected for sequential access.

The RECL specifier takes the following form:

  RECL = rl
  rl
  Is a positive numeric expression indicating the length of records in the file. If necessary, the value is converted to integer data type before use.

  If the file is connected for formatted data transfer, the value must be expressed in bytes (characters). Otherwise, the value is expressed in 4-byte units (longwords). If the file is connected for unformatted data transfer, the value can be expressed in bytes if compiler option /ASSUME=BYTERECL is specified.

The rl value is the length for record data only. It does not include space for control information, such as two segment control bytes (if present) or the bytes that RMS requires for maintaining record length and deleted record control information.

The length specified is interpreted depending on the type of records in the connected file, as follows:

- For segmented records, RECL indicates the maximum length for any segment (not including the two segment control bytes).
- For fixed-length records, RECL indicates the size of each record.
- For variable-length or stream records, RECL specifies the size of the buffer that will be allocated to hold records read or written. Specifying RECL for stream records (STREAM, STREAM_CR or STREAM_LF) is required if the longest record length in the file exceeds the default RECL value.

Errors occur under the following conditions:

- If your program attempts to write to an existing file a record that is longer than the logical record length
- If you are opening an existing file that contains fixed- length records or has relative organization and you specify a value for RECL that is different from the actual length of the records in the file

Table 12-2 lists the maximum values that can be specified for rl for disk files that use the fixed-length record format:

Table 12-2 Maximum Record Lengths (RECL) on OpenVMS Systems

| Record I/O Statement Format
--- | ---
File Organization | Formatted (bytes) | Unformatted (longwords)
Sequential | 32767 | 8191
Relative | 32255 | 8063
Indexed | 32224 | 8056

For other record formats and device types, the record size limit may be less, as described in the OpenVMS Record Management Services Reference Manual.

You must specify RECL when opening new files (STATUS='NEW', 'UNKNOWN', or 'SCRATCH') and one or more of the following conditions exists:

- The file is connected for direct access (ACCESS='DIRECT').
- The record format is fixed length (RECORDTYPE='FIXED').
- The file organization is relative or indexed (ORGANIZATION='RELATIVE' or 'INDEXED').

The default value depends on the setting of the RECORDTYPE specifier, as shown in Table 12-3:

Table 12-3 Default Record Lengths (RECL) on OpenVMS Systems

RECORDTYPE | RECL value
--- | ---
'FIXED' | None; value must be explicitly specified
All other types | 133 bytes (for formatted records) 511 longwords (for unformatted records)

Previous Page Next Page Table of Contents