Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Testing for the ability to use a file exclusive
Message
From
15/01/2000 19:52:13
 
 
To
15/01/2000 14:36:22
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00318595
Message ID:
00318680
Views:
18
>
Rick,
>You could try to fopen() file for RW access. It's silent and doesn't produce error. If you cannot get a positive handle number than it's in use.
>
lnHandle = fopen(myTableName,12)
>if lnHandle < 0 && In use
> * ....
>else
> =fclose(lnHandle)
> use (myTableName) exclusive
>endif
To be more precise and take into account that someone could open it between the few milliseconds (fclose - use) you could set a flag that you're going to get it exclusive to notify other users (ie:write a dummy txt file and check its existence).
>Cetin

There is a flaw with this method. Between the time you do the fclose and the USE, someone else can open the table. The only way to be absolutely sure is to try to USE the table EXCLUSIVE and trap the error if you can't get it.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Reply
Map
View

Click here to load this message in the networking platform