# 12.8 UNLOCK Statement

The UNLOCK statement frees a record in an indexed, relative, or sequential file that was locked by a previous READ statement.

The UNLOCK statement takes one of the following forms:

  UNLOCK ([UNIT=]io-unit [, ERR=label] [, IOSTAT=i-var])
  UNLOCK io-unit
  io-unit
  Is an external unit specifier.
  label
  Is the label of the branch target statement that receives control if an error occurs.
  i-var
  Is a scalar integer variable that is defined as a positive integer if an error occurs and zero if no error occurs.

If no record is locked, the UNLOCK statement has no effect.

Examples

The following statement frees any record previously read and locked in the file connected to I/O unit 4:

      UNLOCK 4

Consider the following statement:

      UNLOCK (UNIT=9, IOSTAT=IOS, ERR=10)

This statement frees any record previously read and locked in the file connected to unit 9. If an error occurs, control is transferred to the statement labeled 10, and a positive integer is stored in variable IOS.

For More Information:

- On the UNIT control specifier, see Section 10.2.1.1.
- On the ERR control specifier, see Section 10.2.1.8.
- On the IOSTAT control specifier, see Section 10.2.1.7.
- On shared files and locked records, see your user manual.

Previous Page Next Page Table of Contents