17.07.2013 Views

GWBASIC User's Manual

GWBASIC User's Manual

GWBASIC User's Manual

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

GW-BASIC <strong>User's</strong> Guide<br />

LOCK Statement<br />

Purpose:<br />

To restrict the access to all or part of a file that has been opened by another process. This is used<br />

in a multi-device environment, often referred to as a network or network environment.<br />

Syntax:<br />

LOCK [#]n [,[record number] [TO record number]]<br />

Comments:<br />

n is the number that was assigned to the file as it was originally numbered in the program.<br />

record number is the number of the individual record that is to be locked. Or, if a range of<br />

records are to be locked, record number designates the beginning and ending record of the<br />

specified range.<br />

The range of legal record numbers is 1 to 2 32 -1. The limit on record size is 32767 bytes.<br />

The record range specified must be from lower to (the same or) higher record numbers.<br />

If a starting record number is not specified, the record number 1 is assumed.<br />

If an ending record number is not specified, then only the specified record is locked.<br />

The following are examples of legal LOCK statements:<br />

LOCK #n locks the entire file n<br />

LOCK #n, X locks record X only<br />

LOCK #n TO Y locks records 1 through Y<br />

LOCK #n, X TO Ylocks records X through Y<br />

With a random-access file, the entire opened file, or a range of records within an opened file, may<br />

be locked, thus denying access to those records to any other process which has also opened the<br />

file.<br />

With a sequential access file that has been opened for input or output, the entire file is locked,<br />

regardless of any record range specified. This is not considered an error. The specification of a<br />

range in the LOCK statement regarding the sequential file will simply be disregarded.<br />

The LOCK statement should be executed on a file or record range within a file before attempting<br />

to read or write to that file.<br />

The locked file or record range should be unlocked before the file is closed. Failure to execute the<br />

UNLOCK statement can jeopardize future access to that file in a network environment.<br />

file:///C|/Documents%20and%20Settings/Lorenzo/Desktop/GW%20Basic/LOCK.html (1 of 2)28/03/2004 21.29.37

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!