Why dost thou hate me REALbasic?

I have been a proponent of REALbasic for years and I never quite understood the wailing & complaining from others.  This has changed for me in the last year and I just don’t understand what the problem is over at REAL Software.  The latest bug that I’ve been bit by really should have been fixed before the 2008 r5.1 release since it was first reported in November of 2008, and the 5.1 release came out in the middle of December 2008.  What is this bug?  I will tell you… StrComp.  Yes, the string compare function is broken if one is apparently using a Unicode text encoding.

dim result as integer
dim s1 as string = “Waves”
dim s2 as string = “voice”

result = StrComp(s1, s2, 1)

MsgBox Str(result) + ” (should be 1)”

‘if s1 < s2 then
‘MsgBox “Yes”
‘MsgBox “No”
‘end if

s1 = Uppercase(s1)
s2 = Uppercase(s2)

result = StrComp(s1, s2, 1)

MsgBox Str(result) + ” (should be 1)”

Take a look at the 3rd parameter of StrComp.  Since we are sending a 1 in, we are telling the function that we don’t care about the case of the strings being compared.  Therefore, “voice” comes before “Waves” and StrComp should return 1.  Instead, it is returning a -1, stating that “Waves” comes before “voice”.  For a product as mature as REALbasic is, I would really like to know how this function broke.  Assuming that REAL Software is performing the dreaded regression tests, this should have been caught before the beta cycle.  Which leads to another interesting question.  Why wasn’t this caught during the beta cycle?  As for one in the beta cycle, all I can say is that I either don’t use StrComp enough or I only use it for case-sensitive comparisons.  While case-insensitive string tests can be done with the IF statement, it does not correctly handle all text encodings.

2 thoughts on “Why dost thou hate me REALbasic?

  1. Bob Keeney

    Have you submitted a FogBugs report and example project? It’s the only way this will get fixed.

    The quick fix is to force all your strings into all upper/lowercase. You might also want to check out MBS string functions as they are generally faster.

  2. Christian Post author

    Yes, I did submit a a bug report with a sample project. I did that prior to posting on the NUG. Hopefully this will be fixed in the next version. Thanks for the tip; I’ll keep that in mind for the future. Currently, I just switched to using the IF statement.

Comments are closed.