Sign in to follow this  
Followers 0
supersonic

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

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Yes, I could say Binary(), Dec(), Hex() or Number() could work too. Just enclose the numericals in them and your off


0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E

Share this post


Link to post
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
Sign in to follow this  
Followers 0