[Gambas-user] Documentation for LOCK

Jussi Lahtinen jussi.lahtinen at gmail.com
Mon Aug 20 15:05:45 CEST 2018


You may want to edit copy of the file and then merge it back to the
original. Otherwise you will create a mess, because user or some other
program does not know what you did to the file.

Jussi

On Mon, Aug 20, 2018 at 2:54 PM Hans Lehmann <hans at gambas-buch.de> wrote:

> 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
>
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20180820/0b076790/attachment.html>


More information about the User mailing list