User Tools

Site Tools


Table of Contents

#$EPIC: switch.txt,v 1.2 2006/08/20 16:57:01 sthalik Exp $


switch (<control text>) { (<switch>) { <body> } }


SWITCH is similar to C's switch statement. It allows for multiple alternatives to a given “control” statement where more than two possible values exist. It is functionally similar to IF except it doesn't require excessive nesting for multiple alternatives.

Whitespace is not significant any any part of SWITCH. Braces may appear anywhere, and multiple switches may appear on the same line or on individual lines. No logic takes place inside the switch, only string comparisons. For this reason, the expression parser is not needed (nor allowed), as everything is assumed to be a string, and variables are expanded.

Breaks and “Fall through” support, as in C, is not supported by EPIC. If you need to perform the same command in multiple switches, it must be present in each switch's body.


A simple switch that checks the value of an arbitrary input:

    switch ( $0 ) {
       ( foo ) {
          <do action for "foo">
       ( bar ) ( blah ) {
          <do action for "bar" or "blah">
       ( * ) {
          <do action for everything else>
switch.txt · Last modified: 2006/08/29 16:08 (external edit)