[Gambas-user] Documentation for LOCK

Hans Lehmann hans at gambas-buch.de
Mon Aug 20 13:53:41 CEST 2018


Hello,

this example can also be found in the documentation for LOCK 
(http://gambaswiki.org/wiki/lang/lock):

8<---------------------------------------------------------

Dim hLock As Stream
' Try to acquire the lock
Try hLock = Lock "~/my-lock"
If Error Then
   Print "Locked is already acquired. Try again later."
   Return
Endif
' File is locked, you can do the job now!
...
' Do not forget to release the lock
Unlock hLock

8<---------------------------------------------------------

and this sentence:

Beware that the locked file is emptied! So never use a file whose 
contents is important.

Doesn't this sentence contradict the above example? I would like to 
protect the file I want to edit exclusively against competing parallel 
access by locking it? The file should not be emptied - I want to edit it!

With kind regards

Hans


More information about the User mailing list