sel expression [flags]
(tab)case a
(tab)case b
[(tab)case else


Statements can be in the case line:


sel expression [flags]
(tab)case a statements
[(tab)case else statements]


All can be in single line:


sel(expression [flags]) case a statements ... [case else statements]



expression - variable or other expression. Type - integer or string.

a, b - integer or string constants. Type must match type of expression.

flags - how to compare strings:

1 case insensitive.
2 use wildcard characters in a, b, ...
4 (QM 2.4.1) use regular expression in a, b, ... that begin with $ character. For example, string "$^a\d+$" is compared as regular expression "^a\d+$". Strings that don't begin with $ are compared as simple strings or strings with wildcard characters (if flag 2 also used).
8 (QM 2.4.1) if expression is 0 (null) compare it as "". Without this flag, null strings don't match "".



If value of expression matches one of case constants, execute statements after that case (until next case, if any). Otherwise, execute statements after case else (if any).


case keyword can be followed by colon.


See also: SelInt, SelStr



 If variable msg is 5, display 1; else if msg is WM_COMMAND, display 2 and play sound; else if msg is 512 or 513 or 514, display 3 and play sound; else display msg:
sel msg
	case 5: out 1
	case WM_COMMAND: out 2; bee
	case [512,513,514]
	out 3
	case else out msg

 Execute different code depending on weekday
str weekday.time("%A")
sel weekday
	case "Monday": out 1
	case "Tuesday"
	out 2
	out "today is Tuesday"
	case ["Sunday","Saturday"]: out 3
	case else out 4

 Execute different code depending on window name
str s.getwintext(win("Quick Macros"))
sel s 3 ;;case insensitive, use wildcards
	case ["*[Macro97]","*[Macro98]"]: out 1 ;;window name ends with [Macro97] or [Macro98]
	case else out 2