Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for Locked Files
Message
 
To
24/06/1999 11:28:18
Paul Frost
Instem Computer Systems Ltd
Stone, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00233514
Message ID:
00233962
Views:
32
>>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.


Here's a way to do this without having to use FOPEN. It actually uses the USe command so there is no danger of someone else grabbing the file before you. You can make changes to allow alias, workarea, again, etc.

FUNCTION MyUse
LPARAMETER lcTableName
LOCAL lcErrorProc,nErrorNum
** Store the old ON ERROR code
lcErrorProc = ON('Error')
** This is the success value
nErrorNum = 0
** Note that we pass the nErrorNum by reference so our
** on error proc can change it
ON ERROR DO NotOpen WITH Error(),nErrorNum

** Try opeing the table
USE &lcTableName

** Reset the error proc
ON ERROR &lcErrorProc
RETURN nErrorNum

FUNCTION NotOpen
LPARAMETER nErrorCode,nErrorNum
nErrorNum = nErrorCode
RETURN
Paul G Brown, MCSD
Paul G Brown
paul@paulgbrown.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform