DreamVB Posted September 25, 2014 Share Posted September 25, 2014 I am trying to use a switch statement to compare chars eg A-Z so if a vaild chat such as A is sent then it will returm true, say you pass something like ÿ it will return false but it seems to return true. very odd like Func IsInSet($char) Switch StringUpper($char) Case "A" To "Z", "a" To "z" Return 1 Case Else Return 0 EndSwitch EndFunc ;==>IsInSet MsgBox(1, "", IsInSet("ÿ")) ; This seems to return 1 even tho it not even in the set why? On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
jchd Posted September 25, 2014 Share Posted September 25, 2014 That looks like a bug with the Switch statement in this case. I advise you post a ticket. In the meantime you can simply use this: MsgBox(1, "", StringRegExp("ÿ", "[[:alpha:]]")) DreamVB 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...
DreamVB Posted September 25, 2014 Author Share Posted September 25, 2014 hi Thanks for the reply I did however find another way around using the values of the chars and seems to work. Func IsInSet($char) Switch Asc(StringUpper($char)) Case 48 To 57 Return 1 Case 65 To 90 Return 1 case 32 Return 1 Case Else Return False EndSwitch EndFunc ;==>IsInSet MsgBox(1,"",IsInSet("ÿ")) On Error Resume Pulling Hair Out. Link to comment Share on other sites More sharing options...
Solution Gianni Posted September 25, 2014 Solution Share Posted September 25, 2014 (edited) I think that the Switch statement is to be used with "numeric" values, expecially if you use the range parameter <value> To <Value> in fact the documentation says <Value> an not <expression> when referring to the range. it seems that the use of "Strings" it works as well, only if you compare a single <expression> in the Switch construct and not using the "To" parameter as range separator. In case of the need to compare ranges you could transform "A" to "Z" in numeric values, for example Asc("A") to Asc("Z") and in this way it works. Func IsInSet($char) Switch Asc(StringUpper($char)) Case Asc("A") To Asc("Z"), Asc("a") To Asc("z") Return 1 Case Else Return 0 EndSwitch EndFunc ;==>IsInSet MsgBox(1, "", IsInSet("ÿ")) ; This seems to return 1 even tho it not even in the set why Edited September 25, 2014 by Chimp DreamVB 1 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...
jchd Posted September 27, 2014 Share Posted September 27, 2014 Beware that by using Asc() instead of AscW() you force a conversion to ANSI. That could silently bite you hard. 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...
Danp2 Posted September 27, 2014 Share Posted September 27, 2014 Why are you checking the range of lowercase letters when you have already converted the character to uppercase? Am I missing something? Latest Webdriver UDF Release Webdriver Wiki FAQs 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