String Compare = true which are not Equal - Forum - OpenEdge Development - Progress Community

String Compare = true which are not Equal

 Forum

String Compare = true which are not Equal

This question is answered

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?

Verified Answer
  • You probably need the COMPARE function.

  • 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+
     
     

  • 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
  • You probably need the COMPARE function.

  • 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+
     
     

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

  • also, trailing spaces are left out of index entries.