Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
LOCK, UNLOCK Statements
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
LOCK limits or prevents access to a file by a network process.
UNLOCK releases the locks imposed by the last LOCK statement.
LOCK [#]filenumber% [,{record& | [start&] TO end&}]
UNLOCK [#]filenumber% [,{record& | [start&] TO end&}]
■ filenumber% The number of an open file.
■ record& For random-access files, the number of a record to
lock, relative to the first record in the file.
For binary files, the number of a byte to lock,
relative to the first byte in the file.
■ start& and end& The numbers of the first and last records or bytes
in a range of records or bytes to lock or unlock.
■ For sequential files, LOCK and UNLOCK affect the entire file.
Example:
'This example runs only in a network environment.
OPEN "TEST.DAT" FOR RANDOM AS #1
FOR i% = 1 TO 10
PUT #1, , i%
NEXT i%
LOCK #1, 2 'Lock record 2.
GET #1, 2, i%
UNLOCK #1, 2 'Unlock record 2.