Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quickly find field names in tables
Message
From
27/06/1997 09:49:22
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00037420
Message ID:
00037925
Views:
30
> > 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? Hmmm... what about aused() for j=1 to aused(aliases) && info on tables used sele aliases(j,2) =afiel(the_stru) && structure of each found_at_pos= ascan(the_stru, myfield) * this be field # in the structure minus 1, times 4 or 9 or whatever the width of ; array returned by aFiel() is worn this season, plus 1 if found_at_pos # 0 the_alias=aliases(i,1) exit endif endfor Now, the bad side of this is if you look for a field named C, D, L, or anything that may match a data type designator. Another, er, feature, is that you might find your field where you don't expect it - say, in another table, or (not sure of this) you might find "CUST" in a table which has "CUSTOM" - better check how aScan() works. Maybe Set Ansi On may be necessary before using this. Disclaimer :) - I wrote this off my head, didn't test it.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform