Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/case.n @ 25

Last change on this file since 25 was 25, checked in by landauf, 17 years ago

added tcl to libs

File size: 2.6 KB
Line 
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'\" RCS: @(#) $Id: case.n,v 1.3 2000/09/07 14:27:46 poenitz Exp $
9'\"
10.so man.macros
11.TH case n 7.0 Tcl "Tcl Built-In Commands"
12.BS
13'\" Note:  do not modify the .SH NAME line immediately below!
14.SH NAME
15case \- Evaluate one of several scripts, depending on a given value
16.SH SYNOPSIS
17\fBcase\fI string \fR?\fBin\fR? \fIpatList body \fR?\fIpatList body \fR...?
18.sp
19\fBcase\fI string \fR?\fBin\fR? {\fIpatList body \fR?\fIpatList body \fR...?}
20.BE
21
22.SH DESCRIPTION
23.PP
24\fINote: the \fBcase\fI command is obsolete and is supported only
25for backward compatibility.  At some point in the future it may be
26removed entirely.  You should use the \fBswitch\fI command instead.\fR
27.PP
28The \fBcase\fR command matches \fIstring\fR against each of
29the \fIpatList\fR arguments in order.
30Each \fIpatList\fR argument is a list of one or
31more patterns.  If any of these patterns matches \fIstring\fR then
32\fBcase\fR evaluates the following \fIbody\fR argument
33by passing it recursively to the Tcl interpreter and returns the result
34of that evaluation.
35Each \fIpatList\fR argument consists of a single
36pattern or list of patterns.  Each pattern may contain any of the wild-cards
37described under \fBstring match\fR.  If a \fIpatList\fR
38argument is \fBdefault\fR, the corresponding body will be evaluated
39if no \fIpatList\fR matches \fIstring\fR.  If no \fIpatList\fR argument
40matches \fIstring\fR and no default is given, then the \fBcase\fR
41command returns an empty string.
42.PP
43Two syntaxes are provided for the \fIpatList\fR and \fIbody\fR arguments.
44The first uses a separate argument for each of the patterns and commands;
45this form is convenient if substitutions are desired on some of the
46patterns or commands.
47The second form places all of the patterns and commands together into
48a single argument; the argument must have proper list structure, with
49the elements of the list being the patterns and commands.
50The second form makes it easy to construct multi-line case commands,
51since the braces around the whole list make it unnecessary to include a
52backslash at the end of each line.
53Since the \fIpatList\fR arguments are in braces in the second form,
54no command or variable substitutions are performed on them;  this makes
55the behavior of the second form different than the first form in some
56cases.
57
58.SH "SEE ALSO"
59switch(n)
60
61.SH KEYWORDS
62case, match, regular expression
Note: See TracBrowser for help on using the repository browser.