Debian Codegraph @

doc/UpVar.3

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