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.

VLR option syntax

Read syntax diagramSkip visual syntax diagramVLR(STANDARDCOMPAT)

Default is: VLR(STANDARD)

Abbreviations are: VLR(C | S)

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.

VLR(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.
VLR(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.

Using VLR(STANDARD) can result in more reliable code and fewer I/O problems because the file status will tell you when a wrong length READ might occur. A new compiler message, MSGIGYP3178, can also help you avoid I/O problems by telling you if a program has a possibility of a wrong length READ. This message can be used to assist with migration from VLR(COMPAT) to VLR(STANDARD) by indicating the possible wrong length READ that you can solve by correcting the File Definition (FD). You can also raise the severity of the message so that the program must be corrected in order to run. To do this, use the MSGEXIT suboption of the EXIT compiler option to change the severity of message MSGIGYP3178 from I (RC=0) to S (RC=12), E (RC=8), or W (RC=4). If you are not interested in seeing this message, you can suppress the message completely.