>
> 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.