Forum Discussion

Simon_InT's avatar
Simon_InT
Contributor
7 years ago
Solved

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)   ...
  • tristaanogre's avatar
    7 years ago

    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')}
  • Simon_InT's avatar
    Simon_InT
    7 years ago

    Thanks tristaanogre, this worked for me.