Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Switch Case with And/Or operator

$
0
0

I suppose something like this can only be done with an if-then statement within the case.

AutoIt         
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?


Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>