- The lock was not set
- Locking a file
- Position in the file
- Operating mode in Windows Vista (and later)
fLock (Function) In french: fBloque Entirely or partially locks an external file. The file will be unlocked: - using the fUnlock function,
- when the file is closed.
The application that locked the file can read this file and write into this file. The other applications cannot read this file or write into this file.
// Open an external file FileID = fOpen("C:\MyDirectories\File.txt", foReadWrite) IF FileID <> -1 THEN ... // Lock the external file ResLock = fLock(FileID) ... END
New in version 28
// Open an external file MyFile is DiskFile MyFile = fOpen("C:\MyDirectories\File.txt", foReadWrite) IF NOT ErrorOccurred THEN ... // Lock the external file ResLock = fLock(MyFile) ... END
Syntax
<Result> = fLock(<File used> [, <First byte to lock> [, <Number of bytes to lock>]])
<Result>: Boolean - True if the file was locked,
- False otherwise.
<File used>: Integer or DiskFile variable <First byte to lock>: Optional integer Position of the first byte to lock (0 corresponds to the first byte of the file). <Number of bytes to lock>: Optional constant or integer - Number of bytes to lock in the file.
- Constant:
| | fLockEmptyFile | fLock has the same behavior whether the file is empty or not (see Remarks). |
Remarks The lock was not set fLock returns False if the file was not locked. The lock can be set only if: - the external file is opened,
- the file identifier is valid,
- the file or the bytes to lock are not already locked by another computer or by another application.
Locking a file - The file is entirely locked if <First byte to lock> and <Number of bytes to lock> are not specified.
- The file is locked from the first byte to lock (<First byte to lock>) until the end if <Number of bytes to lock> is not specified.
- By default, fLock does not lock any bytes if the file is empty. In this case, several applications can successfully "lock" an empty file. However, the file cannot be overwritten as long as it is locked.
To get the same behavior no matter whether the file is empty or not, use the fLockEmptyFile constant. Position in the file When opening a file, the current position corresponds to: - the first file byte (by default),
- the last file byte if the file is opened in "addition" mode (foAdd constant).
This position can be modified by fSeek. The current position does not change when fLock is used. Business / UI classification: Business Logic
This page is also available for…
|
|
|
|