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

Rolf-Werner Eilert eilert-sprachen at ...221...
Tue Jan 19 16:24:10 CET 2010


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?

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




More information about the User mailing list