Lock Range

Locks or unlocks a range of a file specified by refnum. Details

If set lock is TRUE, this function locks the specified range of data in the specified file. If two locked ranges overlap, this function treats them as a single locked range.

If set lock is FALSE (default), this function unlocks the specified range of data in the specified file. If unlocking a subrange of a locked range leaves locked data at either end of the original locked range, this function treats both sets of data as separate locked ranges.

refnum is the file refnum associated with the file you want to lock.
pos mode, together with pos offset, specifies where the lock or unlock operation begins. If the computed location does not exist in the file, for example, pos mode = 0 and pos offset = –10, the file mark does not move, no data is locked or unlocked, and the function returns an error.

If you wire pos offset, pos mode defaults to 0, and the offset is relative to the beginning of the file. If you do not wire pos offset, it defaults to 0, pos mode defaults to 2, and the operation starts at the current file mark. Do not wire these inputs if you want to lock or unlock the data following the most recently accessed data.

0Start—The operation begins at the beginning of the file plus pos offset.
1End—The operation begins at the end of the file plus pos offset.
2Current—The operation begins at the current location of the file mark plus pos offset.
pos offset specifies how far from the location specified by pos mode to start the lock or unlock operation. You express pos offset in units of bytes. The default is 0.

Do not wire pos mode and pos offset if you want to lock or unlock the data following the most recently accessed data.

error in describes error conditions that occur before this VI or function runs. The default is no error. If an error occurred before this VI or function runs, the VI or function passes the error in value to error out. This VI or function runs normally only if no error occurs before this VI or function runs. If an error occurs while this VI or function runs, it runs normally and sets its own error status in error out. Use the Simple Error Handler or General Error Handler VIs to display the description of the error code. Use error in and error out to check errors and to specify execution order by wiring error out from one node to error in of the next node.
status is TRUE (X) if an error occurred before this VI or function ran or FALSE (checkmark) to indicate a warning or that no error occurred before this VI or function ran. The default is FALSE.
code is the error or warning code. The default is 0. If status is TRUE, code is a non-zero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning. The default is an empty string.
count is the number of bytes this function locks or unlocks. You can lock or unlock a range that extends beyond the end of the file to ensure that no other users append to a file while you append to it. This function returns an error if count is less than zero.
dup refnum returns refnum unedited.
error out contains error information. If error in indicates that an error occurred before this VI or function ran, error out contains the same error information. Otherwise, it describes the error status that this VI or function produces. Right-click the error out indicator on the front panel and select Explain Error from the shortcut menu for more information about the error.
status is TRUE (X) if an error occurred or FALSE (checkmark) to indicate a warning or that no error occurred.
code is the error or warning code. If status is TRUE, code is a non-zero error code. If status is FALSE, code is 0 or a warning code.
source describes the origin of the error or warning and is, in most cases, the name of the VI or function that produced the error or warning.

Lock Range Details

Locking a range of a file prevents both reading and writing by other users, overriding permissions for the file, and the deny mode associated with refnum. Unlocking a range of a file removes the override caused by locking a range, so that the file's permissions and the deny mode associated with refnum determine whether other users can read from or write to that range of the file.

Note  You cannot lock a range of a datalog file.