Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Quickly find field names in tables
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00037420
Message ID:
00037422
Vues:
27
>If you have a field name and want to find which table it's in quickly and efficiently, is there anything better than the following:
>
>SELECT table1
>=AFIELDS(aArray1)
>FOR i = 1 TO ALEN(aArray1,1)
>IF myfield = aArray1(i,1)
>itsintable1 = .T.
>ENDIF
>IF itsintable1 = .T.
>SELECT table2
>=AFIELDS(aArray2)
>FOR i = 1 TO ALEN(aArray2,1)
>IF myfield = aArray2(i,1)
>itsintable2 = .T.
>ENDIF
>
>...or is this what I have to do, unless I work around it?

Your code is OK (may be it's nicer to use ASCAN() to scan array), but there is no limit of handling data-related problems in VFP. Next code is just a joke:
lErrorflag=.F.
ON ERROR lErrorflag=.T.
SELECT table2.myfield From table2 Into ...
ON ERROR
IF lErrorflag=.T.
=messagebox("No such field!")
ELSE
=messagebox("Yes, you got it!")
ENDIF
Edward Pikman
Independent Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform