[Gambas-user] LOCK only within OPEN/CLOSE?

Sprachschule Eilert eilert-sprachen at ...221...
Wed Jan 20 12:53:02 CET 2010


Am 19.01.2010 20:06, schrieb Benoît Minisini:
>> Am 19.01.2010 10:57, schrieb Rolf-Werner Eilert:
>>> Just tried to rewrite a function I used for locking files in my Gambas1
>>> apps. It was based on making a directory for locking, and it delivered a
>>> Boolean about if locking was successful or not. Think of it this way:
>>>
>>> Private Function FileIsLocked(filename As String) As Boolean
>>>
>>> Now, when I tried to change the functional part so it uses LOCK instead
>>> of my original mechanism, I get "Useless LOCK". Does this mean, LOCK can
>>> only be used within an OPEN/CLOSE statement? Or maybe only directly
>>> following an OPEN statement? That would be a shame, because this would
>>> mean doing without my own function and including a lot of code into each
>>> OPEN session anywhere it is needed.
>>>
>>> This wouldn't only blow up my code unnecessarily but also require me to
>>> browse through all the places where file locking is used.
>>>
>>> Or did I get this error message wrong?
>>>
>>> Regards
>>>
>>> Rolf
>>
>> Ok, sorry - I found out the reason for my confusion myself :-) I didn't
>> have a look into the online documentation and got confused by the old
>> description given in the installed docs.
>>
>> Isn't it possible to compile the online docs into the distributed ones
>> automagically?
>
> Not easily at the moment. In Gambas 3, I use directly the online doc in a
> Webkit browser with a data cache.
>
>>
>> It seems to run now, though I still have one question left: Is it
>> correct to "open" the file twice, once for LOCK and once for OPEN? In
>> other words: The LOCK statement produces its own stream for the lock
>> file, this is what I understand from it. Then I will have to open it via
>> another stream as usual for reading or writing or whatever.
>>
>> Or how do you use it?
>>
>> Rolf
>>
>
> No, LOCK must be used alone on its file. The file is just there for creating a
> system-global lock. You must not store anything inside this file.
>
> Regards,
>

Thanks for your answer. Is it correct that when I close this stream by 
UNLOCK, it isn't deleted and has to be KILLed programmatically? What 
will happen to another user if his app looks it up after it has been 
UNLOCKed but not deleted?

Regards

Rolf


-- 
Rolf-Werner Eilert

SPRACHSCHULE EILERT
Kollegienwall 19 - 49074 Osnabrück
www.eilert-sprachen.de - 0541/22653




More information about the User mailing list