1case(n)                      Tcl Built-In Commands                     case(n)
2
3
4
5______________________________________________________________________________
6

NAME

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

SYNOPSIS

11       case string ?in? patList body ?patList body ...?
12
13       case string ?in? {patList body ?patList body ...?}
14______________________________________________________________________________
15
16

DESCRIPTION

18       Note:  the  case command is obsolete and is supported only for backward
19       compatibility.  At some point in the future it may be removed entirely.
20       You should use the switch command instead.
21
22       The  case  command matches string against each of the patList arguments
23       in order.  Each patList argument is a list of one or more patterns.  If
24       any  of these patterns matches string then case evaluates the following
25       body argument by passing it recursively  to  the  Tcl  interpreter  and
26       returns  the result of that evaluation.  Each patList argument consists
27       of a single pattern or list of patterns.  Each pattern may contain  any
28       of  the wild-cards described under string match.  If a patList argument
29       is default, the corresponding body will  be  evaluated  if  no  patList
30       matches  string.   If no patList argument matches string and no default
31       is given, then the case command returns an empty string.
32
33       Two syntaxes are provided for the  patList  and  body  arguments.   The
34       first  uses  a separate argument for each of the patterns and commands;
35       this form is convenient if substitutions are desired  on  some  of  the
36       patterns  or  commands.  The second form places all of the patterns and
37       commands together into a single argument; the argument must have proper
38       list  structure,  with  the elements of the list being the patterns and
39       commands.  The second form makes it easy to construct  multi-line  case
40       commands, since the braces around the whole list make it unnecessary to
41       include a backslash at the end of each line.  Since the  patList  argu‐
42       ments  are in braces in the second form, no command or variable substi‐
43       tutions are performed on them;  this makes the behavior of  the  second
44       form different than the first form in some cases.
45
46

SEE ALSO

48       switch(n)
49
50

KEYWORDS

52       case, match, regular expression
53
54
55
56Tcl                                   7.0                              case(n)
Impressum