Seth Woolley's Man Viewer

case(n) - case, case - Evaluate one of several scripts, depending on a given value - man n case

([section] manual, -k keyword, -K [section] search, -f whatis)
man plain no title

case(n)                      Tcl Built-In Commands                     case(n)

       case - Evaluate one of several scripts, depending on a given value

       case string(3,n) ?in(1,8)? patList body ?patList body ...?

       case string(3,n) ?in(1,8)? {patList body ?patList body ...?}

       Note:  the  case command is obsolete and is supported only for backward
       compatibility.  At some point in(1,8) the future it may be removed entirely.
       You should use the switch(1,n) command instead.

       The  case  command matches string(3,n) against each of the patList arguments
       in(1,8) order.  Each patList argument is a list of one or more patterns.  If
       any  of these patterns matches string(3,n) then case evaluates the following
       body argument by passing it recursively  to  the  Tcl  interpreter  and
       returns  the result of that evaluation.  Each patList argument consists
       of a single pattern or list of patterns.  Each pattern may contain  any
       of  the wild-cards described under string(3,n) match.  If a patList argument
       is default, the corresponding body will  be  evaluated  if(3,n)  no  patList
       matches  string(3,n).   If no patList argument matches string(3,n) and no default
       is given, then the case command returns an empty string.

       Two syntaxes are provided for the  patList  and  body  arguments.   The
       first  uses  a separate argument for each of the patterns and commands;
       this form is convenient if(3,n) substitutions are desired  on  some  of  the
       patterns  or  commands.  The second form places all of the patterns and
       commands together into a single argument; the argument must have proper
       list  structure,  with  the elements of the list being the patterns and
       commands.  The second form makes it easy to construct  multi-line  case
       commands, since the braces around the whole list make it unnecessary to
       include a backslash at the end of each line.  Since the  patList  argu-
       ments  are in(1,8) braces in(1,8) the second form, no command or variable substi-
       tutions are performed on them;  this makes the behavior of  the  second
       form different than the first form in(1,8) some cases.


       case, match, regular expression

Tcl                                   7.0                              case(n)

References for this manual (incoming links)