home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / MorphOS / Epic4_mos / share / epic / help / 5_programming / switch < prev    next >
Encoding:
Text File  |  2002-10-28  |  1.3 KB  |  40 lines

  1. Synopsis:
  2.    switch (<control text>) { (<switch>) { <body> } }
  3.  
  4. Description:
  5.    SWITCH is similar to C's switch statement.  It allows for multiple
  6.    alternatives to a given "control" statement where more than two
  7.    possible values exist.  It is functionally similar to IF except it
  8.    doesn't require excessive nesting for multiple alternatives.
  9.  
  10.    Whitespace is not significant any any part of SWITCH.  Braces may
  11.    appear anywhere, and multiple switches may appear on the same line
  12.    or on individual lines.  No logic takes place inside the switch, only
  13.    string comparisons.  For this reason, the expression parser is not
  14.    needed (nor allowed), as everything is assumed to be a string, and
  15.    variables are expanded.
  16.  
  17. Examples:
  18.    A simple switch that checks the value of an arbitrary input:
  19.       switch ( $0 ) {
  20.          ( foo ) {
  21.             <do action for "foo">
  22.          }
  23.          ( bar ) ( blah ) {
  24.             <do action for "bar" or "blah">
  25.          }
  26.          ( * ) {
  27.             <do action for everything else>
  28.          }
  29.       }
  30.  
  31. See Also:
  32.    if(5); fe(5); fec(5)
  33.  
  34. Restrictions:
  35.    EPIC does not support a break-like mechanism, as one would find in C.
  36.    This makes it impossible to implicitly simulate C's "fall-through"
  37.    capability.  FE is better suited to the task of matching multiple
  38.    independent strings.
  39.  
  40.