<HTML><HEAD><TITLE>Tcl Library Procedures - Tcl_UpVar manual page</TITLE></HEAD><BODY> <H3><A NAME="M2">NAME</A></H3> Tcl_UpVar, Tcl_UpVar2 - link one variable to another <H3><A NAME="M3">SYNOPSIS</A></H3> <B>#include <tcl.h></B><BR> int<BR> <B>Tcl_UpVar(</B><I>interp, frameName, sourceName, destName, flags</I><B>)</B><BR> int<BR> <B>Tcl_UpVar2(</B><I>interp, frameName, name1, name2, destName, flags</I><B>)</B><BR> <H3><A NAME="M4">ARGUMENTS</A></H3> <DL> <P><DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD> Interpreter containing variables; also used for error reporting. <P><DT>char <B>*frameName</B> (in)<DD> Identifies the stack frame containing source variable. May have any of the forms accepted by the <B><A HREF="../TclCmd/upvar.htm">upvar</A></B> command, such as <B>#0</B> or <B>1</B>. <P><DT>char <B>*sourceName</B> (in)<DD> Name of source variable, in the frame given by <I>frameName</I>. May refer to a scalar variable or to an array variable with a parenthesized index. <P><DT>char <B>*destName</B> (in)<DD> Name of destination variable, which is to be linked to source variable so that references to <I>destName</I> refer to the other variable. Must not currently exist except as an upvar-ed variable. <P><DT>int <B>flags</B> (in)<DD> Either TCL_GLOBAL_ONLY or 0; if non-zero, then <I>destName</I> is a global variable; otherwise it is a local to the current procedure (or global if no procedure is active). <P><DT>char <B>*name1</B> (in)<DD> First part of source variable's name (scalar name, or name of array without array index). <P><DT>char <B>*name2</B> (in)<DD> If source variable is an element of an array, gives the index of the element. For scalar source variables, is NULL. <P></DL> <H3><A NAME="M5">DESCRIPTION</A></H3> <B>Tcl_UpVar</B> and <B>Tcl_UpVar2</B> provide the same functionality as the <B><A HREF="../TclCmd/upvar.htm">upvar</A></B> command: they make a link from a source variable to a destination variable, so that references to the destination are passed transparently through to the source. The name of the source variable may be specified either as a single string such as <B>xyx</B> or <B>a(24)</B> (by calling <B>Tcl_UpVar</B>) or in two parts where the array name has been separated from the element name (by calling <B>Tcl_UpVar2</B>). The destination variable name is specified in a single string; it may not be an array element. <P> Both procedures return either TCL_OK or TCL_ERROR, and they leave an error message in <I>interp->result</I> if an error occurs. <P> As with the <B><A HREF="../TclCmd/upvar.htm">upvar</A></B> command, the source variable need not exist; if it does exist, unsetting it later does not destroy the link. The destination variable may exist at the time of the call, but if so it must exist as a linked variable. <H3><A NAME="M6">KEYWORDS</A></H3> <A href="../Keywords/L.htm#linked variable">linked variable</A>, <A href="../Keywords/U.htm#upvar">upvar</A>, <A href="../Keywords/V.htm#variable">variable</A> <HR><PRE> <A HREF="../copyright.htm">Copyright</A> © 1994 The Regents of the University of California. <A HREF="../copyright.htm">Copyright</A> © 1994-1996 Sun Microsystems, Inc. <A HREF="../copyright.htm">Copyright</A> © 1995-1997 Roger E. Critchlow Jr.</PRE> </BODY></HTML>