Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Method that fires before the data session is selected?
Message
De
10/04/2008 14:31:32
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01309739
Message ID:
01309773
Vues:
10
Use the default datasession. But do not try to open the table via the datasession. Instead enclose the command in a TRY-ENDTRY inside a custom procedure:
PROCEDURE CheckForExclusive
LOCAL lcTable, llExclOK
lcTable = <path> + <tablename>   && This is whatever path and table
TRY
  USE (lcTable) IN 0 ALIAS excltest EXCLUSIVE
  llExclOK = .T.
  SELECT excltest                && Not sure if you want to close here or 
  USE                            &&   at end of program
CATCH TO loException
  llExclOK = .F.
ENDTRY
RETURN llExclOK
ENDPROC
You can call this as appropriate for your application. You can also do this with a small file. Open it with FOPEN() and this will work. You can set the FOPEN handle to a global attribute:
PROCEDURE CheckForExclusive
LOCAL lcFile
IF !PEMSTATUS(_VFP,"ExclusiveUse",5)
  ADDPROPERTY(_VFP,"ExclusiveUse",0)
ENDIF
lcFile = <path> + <Filename>   && This is whatever path and file
TRY
  _VFP.ExclusiveUse = FOPEN(lcFile,0)
CATCH TO loException
  _VFP.ExclusiveUse = -1
ENDTRY
ENDPROC
Then before the program closes, or whenever you don't want to have exclusive use, perform the following:
PROCEDURE ReleaseExclusive
  =FCLOSE(_VFP.ExclusiveUse)
  _VFP.ExclusiveUse = 0
ENDPROC
You can always check the status of exclusive access via the _VFP.ExclusiveUse being set to positive value.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform