Simon_InT
8 years agoContributor
aqString.Compare
I am using the aqString.Compare and it's returning the incorrect result. The code looks like this:
var String1 = "15";
var String2 = "7"
var test = aqString.Compare(String1, String2, false)
test gets evaluated to -1, meaning String1 is less than String2. Clearly 15 is not less than 7, so I don't understand.
Has anyone else observed this? Is there something I'm doing wrong?
As baxatob pointed out,, aqString.Compare does a character comparison of strings. If you're looking at comparing numeric values to determine if one is less than or greater than another, I would suggest converting the strings to integers and then comparing.
var String1 = "15"; var String2 = "7"; if (aqConvert.StrToInt(String1) < aqConvert.StrToInt(String2)) { Log.Message('Well, this didn't work'); } else { Log.Message('Worked just fine')}
Thanks tristaanogre, this worked for me.