by COBS Tech Support » Thu Jul 13, 2006 2:03 pm
There are a few basics things to watch for when construcitng comparison statements and when dealing with a computer.
(1) Computers treat upper and lower case differently. So "H" does not equal "h". Hence, it's important to use the Upper() function when you are not absolutely sure that both items being compared are always going to be in upper case. The Upper() function converts all characters to upper case for the purposes of the comparison.
(2) Computers may treat strings of unequal length as different. For example, "Hello" and "Hello " may not match because there is an extra space (not visible to humans) at the end of the second variable. To eliminate extra spacing using the Alltrim() function on all variables or database fields being compared.
(3) There are two equivalence operators in CBS. The "=" means match closely and "==" means "match exactly". You will never get a match if you use the "==" operator with two values of different length.
Hence,
Upper(Trim(fieldstring)) = Upper(varstring)
May work, depending on the values of the variables.
But this will always work if both variables are the same:
Upper(Alltrim(fieldstring)) == Upper(Alltrim(varstring))