Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for Locked Files
Message
From
24/06/1999 11:22:29
Paul Frost
Instem Computer Systems Ltd
Stone, United Kingdom
 
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00233514
Message ID:
00233525
Views:
22
>I am running a VFP 6.0 app on a network which is using the same tables I am using. The other app uses the files exclusively. I need to be able to check if the files (cust.dbf) is in use by another computer so my code doesn't bomb out when it goes to to a USE command. I tried ISFLOCKED() but it needs an alias and I can't create the alias without issuing the USE command. HELP!

I use low-level file functions to do the check, these return an error code :

fh = fopen( "cust.dbf" )
if ( fh <> -1 )
fclose( fh )
use cust.dbf
else
wait window "File In Use"
endif

there is the danger that another will grab the file in the small time window between the fclose & the use & there's no guarantee that the -1 return is due to the file already being open - it may not exist for example, but extra code code be put in to test these conditions if required.

If anyone knows a better method, I'd like to know

hth
Paul
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform