Reputation: 23
DEFINE VARIABLE a AS CHARACTER NO-UNDO.
DEFINE VARIABLE b AS CHARACTER NO-UNDO.
a = "123".
b = "123 ".
MESSAGE a = b
VIEW-AS ALERT-BOX.
MESSAGE LENGTH(a) = LENGTH(b)
VIEW-AS ALERT-BOX.
Does anyone know, why the first equals returns true? Are whitespaces ignored on the right side? Because a whitespace on the left would cause the equals to be false. It also doesn't matter how many whitespaces there are on the right side.
Thank you all
Upvotes: 1
Views: 105
Reputation: 3379
The equal comparison ignores trailing blanks. Thus, "abc" is equal to "abc ". However, leading and embedded blanks are treated as characters and " abc" is not equal to "abc".
Upvotes: 3
Reputation: 7192
Well, that's just the way the ABL is implemented.
You can use the COMPARE function.
MESSAGE a = b SKIP
COMPARE (a, "EQ", b, "RAW")
VIEW-AS ALERT-BOX.
Upvotes: 2