set.n
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:2k
- '"
- '" 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: set.n,v 1.3.18.2 2004/10/27 14:23:58 dkf Exp $
- '"
- .so man.macros
- .TH set n "" Tcl "Tcl Built-In Commands"
- .BS
- '" Note: do not modify the .SH NAME line immediately below!
- .SH NAME
- set - Read and write variables
- .SH SYNOPSIS
- fBset fIvarName fR?fIvaluefR?
- .BE
- .SH DESCRIPTION
- .PP
- Returns the value of variable fIvarNamefR.
- If fIvaluefR is specified, then set
- the value of fIvarNamefR to fIvaluefR, creating a new variable
- if one doesn't already exist, and return its value.
- If fIvarNamefR contains an open parenthesis and ends with a
- close parenthesis, then it refers to an array element: the characters
- before the first open parenthesis are the name of the array,
- and the characters between the parentheses are the index within the array.
- Otherwise fIvarNamefR refers to a scalar variable.
- .PP
- If fIvarNamefR includes namespace qualifiers
- (in the array name if it refers to an array element), or if fIvarNamefR
- is unqualified (does not include the names of any containing namespaces)
- but no procedure is active,
- fIvarNamefR refers to a namespace variable
- resolved according to the rules described under fBNAME RESOLUTIONfR in
- the fBnamespacefR manual page.
- .PP
- If a procedure is active and fIvarNamefR is unqualified, then
- fIvarNamefR refers to a parameter or local variable of the procedure,
- unless fIvarNamefR was declared to resolve differently through one of the
- fBglobalfR, fBvariablefR or fBupvarfR commands.
- .SH EXAMPLES
- Store a random number in the variable fIrfR:
- .CS
- fBsetfR r [expr rand()]
- .CE
- .PP
- Store a short message in an array element:
- .CS
- fBsetfR anAry(msg) "Hello, World!"
- .CE
- .PP
- Store a short message in an array element specified by a variable:
- .CS
- fBsetfR elemName "msg"
- fBsetfR anAry($elemName) "Hello, World!"
- .CE
- .PP
- Copy a value into the variable fIoutfR from a variable whose name is
- stored in the fIvblfR (note that it is often easier to use arrays in
- practice instead of doing double-dereferencing):
- .CS
- fBsetfR in0 "small random"
- fBsetfR in1 "large random"
- fBsetfR vbl in[expr {rand() >= 0.5}]
- fBsetfR out [fBsetfR $vbl]
- .CE
- .SH "SEE ALSO"
- expr(n), global(n), namespace(n), proc(n), trace(n), unset(n), upvar(n), variable(n)
- .SH KEYWORDS
- read, write, variable