Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for Locked Files
Message
 
À
24/06/1999 11:28:18
Paul Frost
Instem Computer Systems Ltd
Stone, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
Problèmes
Divers
Thread ID:
00233514
Message ID:
00233962
Vues:
35
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform