case.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
- '"
- '" Copyright (c) 1993 The Regents of the University of California.
- '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
- '"
- '" See the file "license.terms" for information on usage and redistribution
- '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- '"
- '" RCS: @(#) $Id: case.n,v 1.3 2000/09/07 14:27:46 poenitz Exp $
- '"
- .so man.macros
- .TH case n 7.0 Tcl "Tcl Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- case - Evaluate one of several scripts, depending on a given value
- .SH SYNOPSIS
- fBcasefI string fR?fBinfR? fIpatList body fR?fIpatList body fR...?
- .sp
- fBcasefI string fR?fBinfR? {fIpatList body fR?fIpatList body fR...?}
- .BE
- .SH DESCRIPTION
- .PP
- fINote: the fBcasefI command is obsolete and is supported only
- for backward compatibility. At some point in the future it may be
- removed entirely. You should use the fBswitchfI command instead.fR
- .PP
- The fBcasefR command matches fIstringfR against each of
- the fIpatListfR arguments in order.
- Each fIpatListfR argument is a list of one or
- more patterns. If any of these patterns matches fIstringfR then
- fBcasefR evaluates the following fIbodyfR argument
- by passing it recursively to the Tcl interpreter and returns the result
- of that evaluation.
- Each fIpatListfR argument consists of a single
- pattern or list of patterns. Each pattern may contain any of the wild-cards
- described under fBstring matchfR. If a fIpatListfR
- argument is fBdefaultfR, the corresponding body will be evaluated
- if no fIpatListfR matches fIstringfR. If no fIpatListfR argument
- matches fIstringfR and no default is given, then the fBcasefR
- command returns an empty string.
- .PP
- Two syntaxes are provided for the fIpatListfR and fIbodyfR arguments.
- The first uses a separate argument for each of the patterns and commands;
- this form is convenient if 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 fIpatListfR arguments are in braces in the second form,
- no command or variable substitutions are performed on them; this makes
- the behavior of the second form different than the first form in some
- cases.
- .SH "SEE ALSO"
- switch(n)
- .SH KEYWORDS
- case, match, regular expression