Difference between revisions of "LOCK"

From QB64 Wiki
Jump to navigation Jump to search
imported>SMcNeill
imported>SMcNeill
(style guidelines)
Line 1: Line 1:
The {{KW|LOCK}} statement restricts access to parts of a file by other programs or processes.
The [[LOCK]] statement restricts access to parts of a file by other programs or processes.




{{PageSyntax}}
{{PageSyntax}}
:{{KW|LOCK}} [#]{{Parameter|fileNumber%}}
:[[LOCK]] [#]{{Parameter|fileNumber%}}
:{{KW|LOCK}} [#]{{Parameter|fileNumber%}}, {{Parameter|record&}}
:[[LOCK]] [#]{{Parameter|fileNumber%}}, {{Parameter|record&}}
:{{KW|LOCK}} [#]{{Parameter|fileNumber%}}, [{{Parameter|firstRecord&}}] TO {{Parameter|lastRecord&}}
:[[LOCK]] [#]{{Parameter|fileNumber%}}, [{{Parameter|firstRecord&}}] TO {{Parameter|lastRecord&}}




Line 14: Line 14:
* In the third syntax, the records or bytes in the range [{{Parameter|firstRecord&}},{{Parameter|lastRecord&}}] are locked. If {{Parameter|firstRecord&}} is omitted, it is assumed to be one (the first record or byte).
* In the third syntax, the records or bytes in the range [{{Parameter|firstRecord&}},{{Parameter|lastRecord&}}] are locked. If {{Parameter|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.
* 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.
* [[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.
* Files must be unlocked using [[UNLOCK]] before other programs can access them, and before the file is closed.
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword Not Supported in Linux or MAC versions]]
* [[Keywords_currently_not_supported_by_QB64#Keywords_Not_Supported_in_Linux_or_MAC_OSX_versions|Keyword not supported in Linux or macOS versions]]




''Qbasic:''
==QBasic/QuickBasic==
* Requires DOS '''SHARED.EXE''' be run for QBasic to use networking access modes.
* Required DOS '''SHARED.EXE''' to be run for QBasic to use networking access modes. No longer required.




{{PageSeeAlso}}
{{PageSeeAlso}}
* {{KW|UNLOCK}}
* [[UNLOCK]]
* {{KW|OPEN}}
* [[OPEN]]
* {{KW|ACCESS}}
* [[ACCESS]]




{{PageNavigation}}
{{PageNavigation}}

Revision as of 14:16, 9 October 2017

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


Syntax

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


Description

  • 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.
  • Keyword not supported in Linux or macOS versions


QBasic/QuickBasic

  • Required DOS SHARED.EXE to be run for QBasic to use networking access modes. No longer required.


See also



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page