>How can I get the field name associated with an index tag.
>
>For example: the KEY() function returns the index expression, but is there a function to return the field name that the tag belongs to?
>
>If I: INDEX ON UPPER(myfield) TAG mytag, ?KEY('mytable', 1) returns UPPER(myfield). I only want the field myfield returned.
You could adjust one of the parsers offered to match only full words, but the point is that the tag doesn't belong to a field. It is possible, and most commonly done, to use just one field while building the tag, but that doesn't tie the tag to the field, or vice versa. One tag may use several fields in its index expression (or none), and one field may be used in zero or more index expressions.
If you really need to know if a particular field is involved in an index expression, I'd suggest adapting Mark's approach, with the addition of slicing any index expression into just words, like in chrtran(key(), "!#$%&()=+*/[]", space(13)), and then scan it using GetWordCount and GetWordNum (aka Words() and Wordnum() in FoxTools up to VFP6) and use strict comparison. Still, if you have a field named UPPER or DTOC or something like that, you may find it involved in a tag where it actually wasn't.
IMO, it would be much easier to use some of the table/DBC documenting tools and check it visually.