sel expression [flags] (tab) case a (tab) statement (tab) ... (tab) case b (tab) statement (tab) ... (tab) ... [(tab) case else (tab) statement (tab) ...] ...
You can place statements in the same line as case:
sel expression [flags] (tab) case a statements (tab) case b statements [(tab) case else statements] ...
You can place all 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. Can be single value or several values enclosed in square brackets.
statements - any statements.
flags - string comparison options. Combination of the following values: 1 - case insensitive, 2 use wildcard characters in a, b, etc. Default: 0.
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).
sel can be in other block (if, sel, for, ...).
case statement can end with colon.
Unlike with C++ switch, a break is not used. Statements are executed until next case.
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 bee 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