Debian Codegraph @

doc/case.n

raw
1 '\"
2 '\" Copyright (c) 1993 The Regents of the University of California.
3 '\" Copyright (c) 1994-1996 Sun Microsystems, Inc.
4 '\"
5 '\" See the file "license.terms" for information on usage and redistribution
6 '\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
7 '\"
8 .TH case n 7.0 Tcl "Tcl Built-In Commands"
9 .so man.macros
10 .BS
11 '\" Note: do not modify the .SH NAME line immediately below!
12 .SH NAME
13 case \- Evaluate one of several scripts, depending on a given value
14 .SH SYNOPSIS
15 \fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...?
16 .sp
17 \fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?}
18 .BE
19
20 .SH DESCRIPTION
21 .PP
22 \fINote: the \fBcase\fI command is obsolete and is supported only
23 for backward compatibility. At some point in the future it may be
24 removed entirely. You should use the \fBswitch\fI command instead.\fR
25 .PP
26 The \fBcase\fR command matches \fIstring\fR against each of
27 the \fIpatList\fR arguments in order.
28 Each \fIpatList\fR argument is a list of one or
29 more patterns. If any of these patterns matches \fIstring\fR then
30 \fBcase\fR evaluates the following \fIbody\fR argument
31 by passing it recursively to the Tcl interpreter and returns the result
32 of that evaluation.
33 Each \fIpatList\fR argument consists of a single
34 pattern or list of patterns. Each pattern may contain any of the wild-cards
35 described under \fBstring match\fR. If a \fIpatList\fR
36 argument is \fBdefault\fR, the corresponding body will be evaluated
37 if no \fIpatList\fR matches \fIstring\fR. If no \fIpatList\fR argument
38 matches \fIstring\fR and no default is given, then the \fBcase\fR
39 command returns an empty string.
40 .PP
41 Two syntaxes are provided for the \fIpatList\fR and \fIbody\fR arguments.
42 The first uses a separate argument for each of the patterns and commands;
43 this form is convenient if substitutions are desired on some of the
44 patterns or commands.
45 The second form places all of the patterns and commands together into
46 a single argument; the argument must have proper list structure, with
47 the elements of the list being the patterns and commands.
48 The second form makes it easy to construct multi-line case commands,
49 since the braces around the whole list make it unnecessary to include a
50 backslash at the end of each line.
51 Since the \fIpatList\fR arguments are in braces in the second form,
52 no command or variable substitutions are performed on them; this makes
53 the behavior of the second form different than the first form in some
54 cases.
55
56 .SH "SEE ALSO"
57 switch(n)
58
59 .SH KEYWORDS
60 case, match, regular expression