Hi sdpsc,
you already got it, that index on Upper(acolumns(i,1)) will not index correctly. In fact that way you are creating an index with a constant: The field name in upper case. So it's no wonder, that you always get only 1 unique value, e.g. "FIELDNAME" in your index. Simply test it with SEEK "FIELDNAME", whatever the fieldname really is...
But there is one last flaw in your code:
I'd say with you wanted to have an index on the uppercase VALUES of the fields. And with your code:
Code:
clist(i) = upper(acolumns(i,1))
...
index on (&clist(i)) to temp uniq
You again make the field name upper case and index on the field this time. Not on the uppercase values, but on the unchanged values of the field. So "McDonalds" and "Mcdonalds" will count as 2 unique values.
That should work:
Code:
local lnNumfields, lcField, i
local array laFields[1]
lnNumfields = AFields(laFields)
set safety off
set status on
For i = 1 To lnNumFields
lcField = laFields[i,1]
? i, lcField
index on upper(&lcField) to temp uniq
count
Next
Stellas solution with
index on Upper(&aColumns(i,1)) to temp uniq
is almost the same, but I wonder if makro substitution will work correctly for array elements in each vfp version.
Dave Summers: And with evaluate it should be
Upper(Evaluate()), as you want upper of the field value and not the evaluation of the uppercase field name, which is the same as Evaluate() alone, as foxpro isn't case sensitive in field or variable names.