Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is table already open under diff alias?
Message
De
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:
01448216
Vues:
47
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.
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform