If I attempt to gain an exclusive table open in FoxPro, it generates a dialog box if access is denied. Since I'm targeting an non-interactive application, is there a way to detect whether the operation will succeed, or at least have it fail silently?
A:
If you have VFP 8 or greater:
TRY USE MyTable IN 0 EXCLUSIVE ENDTRY ... IF USED ("MyTable") *-- Use the table here ENDIF
izokurew
2009-04-16 18:34:19
Just found that. However, I found that I needed an (empty) CATCH statement.
Justin Love
2009-04-16 18:40:13
A:
For older versions:
cOldError = ON("ERROR")
ON ERROR *
USE MyTable IN 0 EXCLUSIVE
lSuccess = used("MyTable")
ON ERROR &cOldError
if lSuccess ...
Stuart Dunkeld
2009-04-16 19:39:17
A:
I've had success using FOPEN...
nFHdl = FOPEN("myfile.dbf", 1) && 1 tries to open the file for writing
IF nFHdl > 0 THEN
FCLOSE(nFHdl)
USE myfile.dbf exclusive
ELSE
= messagebox("Can't open Exclusive")
ENDIF
ChrisS
2009-11-04 16:58:50