Zohar Posted December 22, 2014 Author Share Posted December 22, 2014 Wow, quite a rich discussion this generated OK, in any case I took Chimp's solution and managed to solve it. If Switch blocks should not support ranges defined by chars, like "a" to "z", then I suggest maybe making it not compile.. So people will not try it, and hence will not waste time on trying to figure out what is wrong.. Link to comment Share on other sites More sharing options...
jchd Posted December 22, 2014 Share Posted December 22, 2014 (edited) binhnx, I didn't see you edited your post in #13. Yet what you say there is wrong: But for one-character-string, AutoIt normalize it to a ansi character. Then ™ becomes t (and ℣ becomes v, ℤ becomes z, but Ω cannot be normalized to ansi.) Unicode ™ (codepoint 0x2122) does not become t in any case. What a conversion (normalization is a different beast) to ANSI yields depends on the ANSI codepage you're using. If your ANSI codepage actually contains the ™ character (e.g. the "western" Windows codepage) then its ASC('™') is returned (0x99 for western Windows) but if your codepage doesn't contain ™ then the conversion gives ? i.e. a question mark. Any Unicode character which doesn't have its exact counterpart in the ANSI codepage you're currently using will convert to ? That's true for Ω and ℣ as well of course. Zohar, This isn't the correct way to handle the situation. Switch is clearly designed to handle strings in conditions and works correctly in all simple cases. Only when several compound condition using strings ranges appear does it go astray. This is definitely a bug and must be raised on Trac and acted upon by Devs. Edited December 22, 2014 by jchd Zohar 1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Gianni Posted December 22, 2014 Share Posted December 22, 2014 <....> Chimp, You and SmOke_N seem to regard Switch as something magical or esoterical but it's not so, even if it is currently buggy in some Case(s) [pun intended]. Your example is no different than: Local $sMsg = "orange" Switch $sMsg Case "apple" To "banana" $sMsgx = "It's a fruit" Case "table" To "bed" $sMsgx = "It's a furniture" Case "Tricycle" To "Car" $sMsg = "It's a vehicle" Case Else $sMsgx = "What's that?" EndSwitch MsgBox(0, $sMsg, $sMsgx) If "apple" <= $sMsg And $sMsg <= "banana" Then $sMsgx = "It's a fruit" ElseIf "table" <= $sMsg And $sMsg <= "bed" Then $sMsgx = "It's a furniture" ElseIf "Tricycle" <= $sMsg And $sMsg <= "Car" Then $sMsg = "It's a vehicle" Else $sMsgx = "What's that?" EndIf MsgBox(0, $sMsg, $sMsgx) Strings are compared lexicographically over case-insensitive UTF-2 character set. How is that difficult to understand? Conditions where <begin> is greater than <end> in a range are simply ignored, irrelevant of datatype(s). Only the implementation --possibly using a buggy jump table or something fancy but wrong-- differs from a sequence of tests. Change "banana" into "zebra" and see by yourself that is works fine, neglecting the fact that a zebra is not a fruit. <....> ok, ... I see ..... "lexicographically" is what I was missing, (a sort of alphabetically ordered) so if we lexicographically (nearly alphabetically) sort the 3 strings: SearchedString <value1> and <value2> and SearchedString falls in between or is equal to <value1> or <value2> then it match thanks for the explanation. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
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