jdelaney Posted May 13, 2013 Share Posted May 13, 2013 (edited) I suppose something like this can only be done with an if-then statement within the case. Local $s = "a", $b = True ConsoleWrite("Switches Return 2? " & Switches($s,$b) & @CRLF) Local $s = "a", $b = False ConsoleWrite("Switches Return 1? " & Switches($s,$b) & @CRLF) Local $s = "a", $b = True ConsoleWrite("Selects Return 2? " & Selects($s,$b) & @CRLF) Local $s = "a", $b = False ConsoleWrite("Selects Return 1? " & Selects($s,$b) & @CRLF) Func Selects($string, $bool) Select Case $string = "a" Or $bool Return 1 Case $string = "a" And $bool Return 2 Case $string = "a" Return 3 Case Else Return 4 EndSelect EndFunc Func Switches($string, $bool) Switch $string Case "a" Or $bool Return 1 Case "a" And $bool Return 2 Case "a" Return 3 Case Else Return 4 EndSwitch EndFunc output Switches Return 2? 1 Switches Return 1? 1 Selects Return 2? 1 Selects Return 1? 1 Maybe these should cause syntax errors? Edited May 13, 2013 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Solution jchd Posted May 13, 2013 Solution Share Posted May 13, 2013 (edited) A little modification can help there. First notice that you must test for AND before OR, else the OR condition will predate the AND. Also you will never return 3 since the preceeding test will trigger a return in all cases ($bool is free here). Then you have several choices, among them: Local $s = "a", $b = True ConsoleWrite("Switches Return 2? " & Switches($s,$b) & @CRLF) Local $s = "a", $b = False ConsoleWrite("Switches Return 1? " & Switches($s,$b) & @CRLF) Local $s = "a", $b = True ConsoleWrite("Selects Return 2? " & Selects($s,$b) & @CRLF) Local $s = "a", $b = False ConsoleWrite("Selects Return 1? " & Selects($s,$b) & @CRLF) Func Selects($string, $bool) Select Case ($string = "a") And $bool Return 2 Case ($string = "a") Or $bool Return 1 Case $string = "a" Return 3 ; can never occur! Case Else Return 4 EndSelect EndFunc Func Switches($string, $bool) Switch (($string = "a") + 0) & ($bool + 0) Case "11" Return 2 Case "01", "10" Return 1 Case "a" Return 3 ; can never occur! Case Else Return 4 EndSwitch EndFunc Edited May 13, 2013 by jchd 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...
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