>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)