Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking if table in use
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00950216
Message ID:
00950299
Views:
13
Hi Frank,

As discussed recently in another thread tcAlias is not necessary the table, which you're trying to open exclusively.

Actually, this presents a little bit of a problem, which requires a solution. Here is the problem:

You pass the table name and the alias.
The alias could be already in use, but is it the same table?

If not, do we want to close this table? But what if the passed table could not be opened exclusive?


>>I don't want to get error message if the table used!
>
>Use the Try-Catch in a method and return succes.
>
>
>Something like
>
>
 PROCEDURE OpenExclusive(tcAlias as String) as Boolean
>local llRetVal
>
>llRetVal = .T.
>
>if used(tcAlias)
>    select (tcAlias)
>
>else
>    select 0
>
>endif
>
>
>TRY
>    use (tcAlias) exclusive
>
>CATCH
>    *-- nope!
>    llRetVal = .F.
>
>ENDTRY
>
>return llRetVal
>ENDPROC
>
>then You can call it
>
>
>if OpenExclusive("Test")
>   *-- do my exclusive stuff
>else
>   *-- display a message or do something different
>endif
>
>
>Oh, and if You do not Have VFP 8+ You'll need to do something like this instead of the try..catch
>
>
>*-- disable the ErrorHandler
>lcWasError = on("ERROR")
>on ERROR *
>
>....
>
>use (tcAlias) exclusive
>
>llRetVal = used(tcAlias)
>
>*-- and reEnable the ErrorHandler
>on error &lcWasError
>
>
>
>HTH
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform