Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Finding, if file is used exclusively
Message
 
 
To
05/10/2000 00:09:17
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00425134
Message ID:
00425176
Views:
26
>>I've been using the following for years (since the DOS days...)
>>
>>PARAMETERS filename
>>fh = FOPEN(filename, 12)
>>IF fh > 0
>> =FCLOSE(fh)
>> RETURN (ok to use exclusively...)
>>ELSE
>> RETURN (file is in use, try again later...)
>>ENDIF
>>
>>Hope this helps,
>>
>>-Rick
>
>This can fail. Another user can grab the table between the RETURN and USE EXCLUSIVE. I'm not saying it will, but the possibility is there.

You could reduce the probability of this by an incredibly small amount by doing the close and return at the same time:
RETURN fh > 0 AND FCLOSE(fh)
This way the close does not happen until the very last moment. And because VFP evaluates expressions from left to right and there is an AND, if the file was not opened then the FCLOSE() will not be attempted.
censored.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform