String Compare = true which are not Equal

Posted by Stefan Marquardt on 01-Jun-2018 01:46

15 years ABL or longer and I wasn't aware of this feature. :-)

I know that default is not case sensitive but that spaces are handled similar I didn't know.

define variable cTest as character no-undo.

cTest = " ".

message cTest = "" view-as alert-box.    -> yes|true

 

So, a [space] is equal to [blank]

Coming from the MS world it's confusing.

 

Help:

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".

 

It describes the behaviour.

 

But when the operators = and EQ defines not really equal values to equal, which ABL command makes a trusted compare without being more intelligent as the user?

Posted by Richard.Kelters on 01-Jun-2018 02:48

You probably need the COMPARE function.

Posted by Brian K. Maher on 01-Jun-2018 05:22

COMPARE function or perhaps IF cTest = “” and LENGTH(cTest) = LENGTH(“”)
 
 
Brian Maher
Principal Engineer, Technical Support
Progress
Progress
14 Oak Park | Bedford, MA 01730 | USA
phone
+1 781 280 3075
 
 
Twitter
Facebook
LinkedIn
Google+
 
 

Posted by Stefan Marquardt on 01-Jun-2018 05:30

Hi Richard,

I tested Compare and it works as expected (by me) although I used EQ as comperator too.

So within Compare "EQ" as relation-operator is different than using EQ operator.

Very confusing because the relation-operators are not descibed in the help.

define variable cTest as character no-undo.

cTest = " ".

message cTest = "" view-as alert-box.    

MESSAGE COMPARE (cTest, "=", "", "CAPS").

From my logical view it's not stringent (german word)

I have to be aware of it that for 100% comparision I need to use the longer COMPARE function.

Thank you for your annotation.

All Replies

Posted by Richard.Kelters on 01-Jun-2018 02:48

You probably need the COMPARE function.

Posted by Brian K. Maher on 01-Jun-2018 05:22

COMPARE function or perhaps IF cTest = “” and LENGTH(cTest) = LENGTH(“”)
 
 
Brian Maher
Principal Engineer, Technical Support
Progress
Progress
14 Oak Park | Bedford, MA 01730 | USA
phone
+1 781 280 3075
 
 
Twitter
Facebook
LinkedIn
Google+
 
 

Posted by Stefan Marquardt on 01-Jun-2018 05:30

Hi Richard,

I tested Compare and it works as expected (by me) although I used EQ as comperator too.

So within Compare "EQ" as relation-operator is different than using EQ operator.

Very confusing because the relation-operators are not descibed in the help.

define variable cTest as character no-undo.

cTest = " ".

message cTest = "" view-as alert-box.    

MESSAGE COMPARE (cTest, "=", "", "CAPS").

From my logical view it's not stringent (german word)

I have to be aware of it that for 100% comparision I need to use the longer COMPARE function.

Thank you for your annotation.

Posted by gus bjorklund on 01-Jun-2018 07:08

also, trailing spaces are left out of index entries.

This thread is closed