1Tcl_UpVar(3) Tcl Library Procedures Tcl_UpVar(3)
2
3
4
5______________________________________________________________________________
6
8 Tcl_UpVar, Tcl_UpVar2 - link one variable to another
9
11 #include <tcl.h>
12
13 int
14 Tcl_UpVar(interp, frameName, sourceName, destName, flags)
15
16 int
17 Tcl_UpVar2(interp, frameName, name1, name2, destName, flags)
18
20 Tcl_Interp *interp (in) Interpreter containing
21 variables; also used for
22 error reporting.
23
24 CONST char *frameName (in) Identifies the stack
25 frame containing source
26 variable. May have any
27 of the forms accepted by
28 the upvar command, such
29 as #0 or 1.
30
31 CONST char *sourceName (in) Name of source variable,
32 in the frame given by
33 frameName. May refer to
34 a scalar variable or to
35 an array variable with a
36 parenthesized index.
37
38 CONST char *destName (in) Name of destination vari‐
39 able, which is to be
40 linked to source variable
41 so that references to
42 destName refer to the
43 other variable. Must not
44 currently exist except as
45 an upvar-ed variable.
46
47 int flags (in) Either TCL_GLOBAL_ONLY or
48 0; if non-zero, then
49 destName is a global
50 variable; otherwise it
51 is a local to the current
52 procedure (or global if
53 no procedure is active).
54
55 CONST char *name1 (in) First part of source
56 variable's name (scalar
57 name, or name of array
58 without array index).
59
60 CONST char *name2 (in) If source variable is an
61 element of an array,
62 gives the index of the
63 element. For scalar
64 source variables, is
65 NULL.
66_________________________________________________________________
67
68
70 Tcl_UpVar and Tcl_UpVar2 provide the same functionality as the upvar
71 command: they make a link from a source variable to a destination
72 variable, so that references to the destination are passed transpar‐
73 ently through to the source. The name of the source variable may be
74 specified either as a single string such as xyx or a(24) (by calling
75 Tcl_UpVar) or in two parts where the array name has been separated from
76 the element name (by calling Tcl_UpVar2). The destination variable
77 name is specified in a single string; it may not be an array element.
78
79 Both procedures return either TCL_OK or TCL_ERROR, and they leave an
80 error message in the interpreter's result if an error occurs.
81
82 As with the upvar command, the source variable need not exist; if it
83 does exist, unsetting it later does not destroy the link. The destina‐
84 tion variable may exist at the time of the call, but if so it must
85 exist as a linked variable.
86
87
89 linked variable, upvar, variable
90
91
92
93Tcl 7.4 Tcl_UpVar(3)