>> if not (alltrim(x) == alltrim(y))
>> n = n + 1
>> the statement evaluates to TRUE, and n is incremented.
>> Anyone have any ideas why
Maybe because the condition is TRUE!
If x = "abc" and y = " " then ALLTRIM(x) is not equal to ALLTRIM(y) and the for inequality is TRUE and so it should execute the loop. Remember, the part inside the parenthesis is executed first. So this statement comp[ares the values and then evaluates whether the result is true or false. Since you are testing for the NOT (i.e. statement is false) condition, the result is TRUE when the values are not identical.
The only time it will not execute, as you have it written, is if: ALLTRIM( x ) == ALLTRIM( y ), because then the statement is true and the NOT condifition is false!