|
From: Donald G P. <dg...@ni...> - 2004-03-30 22:16:56
|
> > upvar 0 x(1) y(1)
> >
> > which creates a /scalar/ variable named y(1) that is linked to the
> > element 1 of the array x. However, there is no way for a tcl script to
> > read or write such scalar variables, the parser will interpret that
> > name as referring to an element of the array named y.
>
> % global x(1)
> % set {x(1)} foo
> foo
> % puts ${x(1)}
> foo
% array get x
1 foo
This example demonstrates the point. Everything you try at the script
level will treat the variable name "x(1)" as element "1" in array
variable "x". Nothing will succeed in treating the variable name
"x(1)" as the name of a scalar variable independent of any array.
More detail:
% set a 1
1
% upvar 0 a bad(var)
% set a
1
% set bad(var)
can't read "bad(var)": no such variable
% array exists bad
0
% set bad(var) 3
3
% set a
1
% array get bad
var 3
| Don Porter Mathematical and Computational Sciences Division |
| don...@ni... Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
|