Jump to content

Trying to compare with StringCompare() fails...!?


Recommended Posts

Hi!

When comparing different values with StringCompare() I got the following results:

StringCompare("98", "99") = -1 (OK.)

StringCompare("99", "98") = 1 (OK.)

StringCompare("99", "99") = 0 (OK.)

StringCompare("100", "99") = -1 (Shouldn't it be "1"?)

StringCompare("150", "99") = -1 (Shouldn't it be "1"?)

Same behaviour when using "If":

If $aVal1[$j] > $aVal2[$j] Then
            Return 1
        ElseIf $aVal1[$j] < $aVal2[$j] Then
            Return -1
        EndIf

Any ideas?

Greets,

-supersonic.

Edited by supersonic
Link to comment
Share on other sites

Your firstly using a string to compare these values. so by default 0 would be the losest and 9 the highest. so you need to implement the true case in here.

StringCompare("100","099") = 1

However your using numericals so you should call a another function. Need a function that turns the numerical into digits and do the calculation when I get home tonight unless you will create it

0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Link to comment
Share on other sites

You're right! :)

Using the function Number() will solve my issue.

Your firstly using a string to compare these values. so by default 0 would be the losest and 9 the highest. so you need to implement the true case in here.

StringCompare("100","099") = 1

However your using numericals so you should call a another function. Need a function that turns the numerical into digits and do the calculation when I get home tonight unless you will create it

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...