1 | '\" |
---|
2 | '\" Copyright (c) 1994 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: UpVar.3,v 1.11 2006/10/09 23:38:56 msofer Exp $ |
---|
9 | '\" |
---|
10 | .so man.macros |
---|
11 | .TH Tcl_UpVar 3 7.4 Tcl "Tcl Library Procedures" |
---|
12 | .BS |
---|
13 | .SH NAME |
---|
14 | Tcl_UpVar, Tcl_UpVar2 \- link one variable to another |
---|
15 | .SH SYNOPSIS |
---|
16 | .nf |
---|
17 | \fB#include <tcl.h>\fR |
---|
18 | .sp |
---|
19 | int |
---|
20 | \fBTcl_UpVar(\fIinterp, frameName, sourceName, destName, flags\fB)\fR |
---|
21 | .sp |
---|
22 | int |
---|
23 | \fBTcl_UpVar2(\fIinterp, frameName, name1, name2, destName, flags\fB)\fR |
---|
24 | .SH ARGUMENTS |
---|
25 | .AS "const char" *sourceName |
---|
26 | .AP Tcl_Interp *interp in |
---|
27 | Interpreter containing variables; also used for error reporting. |
---|
28 | .AP "const char" *frameName in |
---|
29 | Identifies the stack frame containing source variable. |
---|
30 | May have any of the forms accepted by |
---|
31 | the \fBupvar\fR command, such as \fB#0\fR or \fB1\fR. |
---|
32 | .AP "const char" *sourceName in |
---|
33 | Name of source variable, in the frame given by \fIframeName\fR. |
---|
34 | May refer to a scalar variable or to an array variable with a |
---|
35 | parenthesized index. |
---|
36 | .AP "const char" *destName in |
---|
37 | Name of destination variable, which is to be linked to source |
---|
38 | variable so that references to \fIdestName\fR |
---|
39 | refer to the other variable. Must not currently exist except as |
---|
40 | an upvar-ed variable. |
---|
41 | .AP int flags in |
---|
42 | One of \fBTCL_GLOBAL_ONLY\fR, \fBTCL_NAMESPACE_ONLY\fR or 0; if non-zero, |
---|
43 | then \fIdestName\fR is a global or namespace variable; otherwise it is |
---|
44 | local to the current procedure (or current namespace if no procedure is |
---|
45 | active). |
---|
46 | .AP "const char" *name1 in |
---|
47 | First part of source variable's name (scalar name, or name of array |
---|
48 | without array index). |
---|
49 | .AP "const char" *name2 in |
---|
50 | If source variable is an element of an array, gives the index of the element. |
---|
51 | For scalar source variables, is NULL. |
---|
52 | .BE |
---|
53 | |
---|
54 | .SH DESCRIPTION |
---|
55 | .PP |
---|
56 | \fBTcl_UpVar\fR and \fBTcl_UpVar2\fR provide the same functionality |
---|
57 | as the \fBupvar\fR command: they make a link from a source variable |
---|
58 | to a destination variable, so that references to the destination are |
---|
59 | passed transparently through to the source. |
---|
60 | The name of the source variable may be specified either as a single |
---|
61 | string such as \fBxyx\fR or \fBa(24)\fR (by calling \fBTcl_UpVar\fR) |
---|
62 | or in two parts where the array name has been separated from the |
---|
63 | element name (by calling \fBTcl_UpVar2\fR). |
---|
64 | The destination variable name is specified in a single string; it |
---|
65 | may not be an array element. |
---|
66 | .PP |
---|
67 | Both procedures return either \fBTCL_OK\fR or \fBTCL_ERROR\fR, and they |
---|
68 | leave an error message in the interpreter's result if an error occurs. |
---|
69 | .PP |
---|
70 | As with the \fBupvar\fR command, the source variable need not exist; |
---|
71 | if it does exist, unsetting it later does not destroy the link. The |
---|
72 | destination variable may exist at the time of the call, but if so |
---|
73 | it must exist as a linked variable. |
---|
74 | |
---|
75 | .SH KEYWORDS |
---|
76 | linked variable, upvar, variable |
---|