# switch Flow control command
Syntax
    switch [-s] (<expression>)
    {
        case(<value>)[:]<command>
        [break]
        match(<wildcard_expression>)[:]<command>
        [break]
        regexpr(<regular_expression>)[:]<command>
        [break]
        default[:]<command>
        [break]
    }
Description
This command is similar to the C switch: it just has some extended "case" labels. Fist evaluates expression, then executes each internal label in the following way. The <value> in the "case" label is compared with the result of the expresison evaluation. If the result is equal to <value> then the corresponding <command1> is executed. In the "match" labels the result of the expression evaluation is matched in <wildcard_expression>. <wildcard_expression> can contain the usual * and ? wildcard characters. If the expression matches then the corresponding <command> is executed. In the "regexpr" labels the result of <expression> evaluation is matched against a real regular expression. If the regular expression matches then the corresponding command is executed. The default label is executed unconditionally if no other labels matched. If the break command is used in an executed <command> then the next labels are not evaluated. If break is not used then all the labels are evaluated sequentially and multiple matches are possible. If the -s switch is used then the comparisons become case sensitive. TODO: Write some examples :D
Examples
        %x = 1
        switch(%x)
        {
            case(0): echo It was 0!
            case(1): echo It was 1!
        }

Main, Commands

KVIrc 3.0.0 Documentation
Generated by root at Thu Apr 7 23:58:20 2005