Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is table already open under diff alias?
Message
 
 
À
08/02/2010 15:36:24
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., Nouvelle Zélande
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01448039
Message ID:
01448218
Vues:
48
>To check if the certain table is opened in the particular DS you need to use aUsed() function.
>
>I'm missing something... why not just the USED() function? The only problem I see is if the table could have some other alias, meaning USED() and aUSED() won't spot it.
>
>
>USE mytable ALIAS someother
>? USED('mytable') &&returns .F.
>=aUSED(aTables)
>? aTables(1,1) &&returns SOMEOTHER, not mytable
>
>
>Then you'd need to use the DBF() function to iterate through looking for an alias with the correct underlying table. Seems like a lot of work.
>
>How about
>
>
>Local llMyAliasOpen
>Select 0
>llMyAliasOpen=.F.
>Try
>	Use mytable Again Alias myalias
>Catch
>	*---myalias is open now one way or another...
>	*---flag this so it doesn't get closed at end of routine
>	llMyAliasOpen=.T.
>Finally
>
>
>You have to use ALIAS or it will reopen the table with A, B. C... aliases. You can open it ALIAS mytable if you want to use the tablename. It would be much more complex if you want to use any existing alias for that table that may happen to be open, but that's time for a redesign IMHO.

I think we're drifting from the original problem. The original problem was to check if the particular table is opened under any alias. Your code (without again) will work, e.g.
Local llMyTableOpened

>llMyTableOpen=.F.
>Try
>	Use mytable Alias UsedJustToCheck  in 0 shared
>Catch
>	*---myalias is open now one way or another...
>	*---flag this so it doesn't get closed at end of routine
>	llMyTableOpen=.T.
>Finally
   use in select('UsedJustToCheck')
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform