Command: switch

Syntax

switch <gen_value> {
    case <values>: <command_block>
    ...
    default: <command_block>
}

Description

Execute a command or block of commands on the result of a multi-way decision.

Parameters

Switches

Examples

switch x {
    case 1: y=x; # Execute one command
    case 2: { y=x; z=x } # Execute a command block
    case 3: null; # No action
    case 4,5,6: x=25; # Multiple choice
    case xs[1:10]: x=35; # Choice from array range
    default: x=50; # Default action
}
switch ss, -w {
    case 'a*': | ss begins with a
    case 'b*': | ss beigns with b
    default: !ss begins with neither a nor b
}