Hi Al,
I don't want to sound as I criticize, but I think there is no need for such check. If the file can be opened exclusive right this second, it may not be opened a second later. Therefore, you need an OpenTble method instead.
May Slay recently worked on his code for such method, do you want me to point out?
BTW, the syntax itself in your code is correct, IMHO.
Actually, I just re-read the purpose of this method. Do you think opening file exclusively is a test for no corruption?
>I've got a simple method, CanOpen() which tests if a passed .dbf file name can actually be opened (i.e. it's not corrupted, etc.) The former version used ON ERROR and worked fine, but I've decided to update it to use TRY...CATCH instead.
>
>LPARAMETERS ;
> tcConfigFile
>
>LOCAL ;
> llRetVal
>
>llRetVal = .T.
>
>TRY
> USE ( tcConfigFile ) ALIAS Config IN 0 EXCLUSIVE
>
>CATCH
> llRetVal = .F.
>
>ENDTRY
>
>IF USED( "Config" )
> USE IN Config
>
>ENDIF
>
>RETURN llRetVal
>
>In testing, this code *seems* to return the correct value, but I'm getting some side effects. I have a log file open with SET TEXTMERGE TO ..., and after this code runs messages no longer get written to the log file.
>
>I haven't used TRY...CATCH much, maybe I've got the syntax completely wrong.
If it's not broken, fix it until it is.
My Blog