LOCK - QB64 Wiki


From QB64 Wiki

Jump to: navigation, search

The LOCK statement restricts access to parts of a file by other programs or processes.


LOCK [#]fileNumber%
LOCK [#]fileNumber%, record&
LOCK [#]fileNumber%, [firstRecord&] TO lastRecord&


  • fileNumber% is the file number of the file to lock.
  • In the first syntax, the entire file is locked.
  • In the second syntax, record& is the record number of the file to lock.
  • In the third syntax, the records or bytes in the range [firstRecord&,lastRecord&] are locked. If firstRecord& is omitted, it is assumed to be one (the first record or byte).
  • For files opened in BINARY mode, each record corresponds to a single byte.
  • LOCK and UNLOCK statements are always used in pairs and each statement must match the other one.
  • Files must be unlocked using UNLOCK before other programs can access them, and before the file is closed.
  • Requires DOS SHARED.EXE be run for QBasic to use networking access modes.
  • Keyword Not Supported in Linux or MAC versions

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in
  • What links here
  • Related changes
  • Special pages
  • Printable version