Unlock Statement

Syntax

Unlock [#]filenumber[, recordrange]


filenumber

Use: Required

Data Type: Integer

Any valid file number.


recordrange

Use: Optional

Data Type: Long

A range of records.

The syntax for the recordrange argument is:

recnumber | [start] To end


recnumber

Use: Required

Data Type: Long

The record or byte number to unlock.


start

Use: Optional

Data Type: Long

The first record or byte number to unlock.


end

Use: Required

Data Type: Long

The last record or byte number to unlock.

Description

Use the Unlock statement in situations where more than one part of your program may need read and write access to the same data file. The Unlock statement removes a lock placed on a section or the whole file that was locked with the Lock statement.

Rules at a Glance

  • Records and bytes in a file are always numbered sequentially from 1 onwards.

  • To unlock a particular record, specify its record number and only that record is unlocked.

  • Use the Unlock statement omitting recnumber to unlock the whole file.

  • The Unlock statement unlocks an entire file opened in input or output (sequential) mode, regardless of the recordrangeargument.

  • If you omit the start argument in the recnumber syntax, Unlock unlocks all records from the start of the file to record or byte number end.

Programming Tips and Gotchas

  • You must take care to remove all file locks using the Unlock statement before either closing a file or ending the application; otherwise, you can leave the file in an unstable state. This, of course, means that, where appropriate, your error handling routines must be made aware of any locks you currently have in place so that they may be removed if necessary.

  • You use the Lock and Unlock statements in pairs, and the argument lists of both statements must match exactly.

See Also

Lock Statement
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.161.165