Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Check to see if a table on a network drive is in use
Message
From
10/06/2003 10:50:07
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
10/06/2003 10:47:15
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00798363
Message ID:
00798393
Views:
31
>Is there a way I can check if a file is open before trying to open it using the USE command?
>
>e.g.
>
>IF ALREADYOPEN("mytable")
> =MESSAGEBOX("Mytable is already open by another user",48,"")
>ELSE
> USE mytable IN 0 ALIAS mytable
>ENDIF
>
>ALREADYOPEN being a purely fictional command.

I think it is easier to check "after you open it", that is, use error handling. For instance:
local llFileError
ON ERROR llFileError = .T.
use MyTable
ON ERROR
if llFileError
  MessageBox("Can't open table.")
else
  (Continue processing)
endif
This has to be adjusted if you already have an error handler for your application (save your "on error" and restore it later).

Or, of you have VFP8, better use TRY...CATCH (see this month's issue of the Universal Thread Magazine).

HTH,

Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform