dianaManolito Posted February 23, 2007 Posted February 23, 2007 Hi !I have a trouble with string comparison. Apparently, the following snippet returns : "yes"if "-" < "1" then MsgBox(1,"","yes")ELSE MsgBox(1,"","no")EndIf----------------The second snippet returns : "no" if "-1" < "1" then MsgBox(1,"","yes")ELSE MsgBox(1,"","no")EndIf-----------How is this possible if this is a string comparison. "-" (dash) has the ASCII code 45 and is smaller than the ASCII code for 1 (which is 49). How is the sorting of strings performed? :::::Compare the first letter=> if equal, go to next one. If the second letter is smaller(/greater), take the decision. Or is some other method used? ex: The database "ORDER BY " clause seems to have this behavior. Can you help me with this? How can i force the AUTOit to compare each character separately? Thanks, Manolito
Shevilie Posted February 23, 2007 Posted February 23, 2007 Well you couls make your own sort function Split the string and compare as you descripe Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Moderators SmOke_N Posted February 23, 2007 Moderators Posted February 23, 2007 (edited) Strings are not numbers. They aren't converted to ASCII code values without you specifically telling them to do so. So your < or > attempt is not on the specific characters on the string but the actual "string" value itself. Edited February 23, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
dianaManolito Posted February 23, 2007 Author Posted February 23, 2007 Thanks Larry, your example is a common sense one , but i still don't like the following AUTOIT sorting : - 1 -1 ??
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now