filelock
Locks the specified file.
filelock <file handle> [<timeout>]
Remarks
Locks the specified whole file.
The lock is advisory (flock): while the file is locked, other programs that use locks (such as other macros) can not lock it, but programs that do not use locks can still read and write the file.
The <timeout> argument is described below.
| <timeout> | Description |
|---|---|
| 0 | Returns quickly the error when the file is already locked. |
| Abbreviation | Returns only when the file is unlocked. |
| Value | Waits until the file is unlocked or the time-out interval(in seconds) elapses. Returns the error when the time-out interval elapsed. |
If the function succeeds, the system variable "result" is set to 0.
If the function fails, the system variable "result" is set to 1.
Examples
fileopen fhandle 'test.txt' 0 filelock fhandle if result!=0 then messagebox 'error' 'hoge' endif filewrite fhandle 'sample' pause 60 fileunlock fhandle if result!=0 then messagebox 'error' 'hoge' endif fileclose fhandle