VLR

The VLR option affects the file status returned from READ statements for variable-length records when the length of record returned is inconsistent with the record descriptions. It eases your migration from earlier versions to Enterprise COBOL V6, if your programs have READ statements that result in a record length conflict.

Syntax

Read syntax diagramSkip visual syntax diagramVLR=*STANDARDCOMPAT
Default
VLR=STANDARD
After the execution of a READ statement:
  • If the number of character positions in the record that is read is less than the minimum size specified by the record description entries for the file, the portion of the record area that is to the right of the last valid character read is undefined.
  • If the number of character positions in the record that is read is greater than the maximum size specified by the record description entries for the file, the record is truncated on the right to the maximum size.

In either of these cases, the READ statement is successful, and the file status is set to either 00 (hiding the record length conflict condition) or 04 (indicating that a record length conflict has occurred), depending on the VLR compiler option setting.

COMPAT
If you specify VLR=COMPAT, you get the status value of 00 when READ statements encounter a record length conflict.
Note: This setting can hide I/O problems that can arise with the wrong length read situation. Use the VLR=COMPAT option with caution, and check for correct READ statements.
STANDARD
If you specify VLR=STANDARD, you get the status value of 04 when READ statements encounter a record length conflict.

You can add code to test for FS=04 to avoid accessing undefined data in a record and also avoid getting protection exceptions for attempting to reference a part of the record that was truncated.