accessing to a variable by ref (variable is an array) 
Author Message
 accessing to a variable by ref (variable is an array)

i try to access to an array named a, his name is stored in another variable , b.
how to do that?
Thank you
Stefano

(porrino) 49 % set a(1) ciao
ciao
(porrino) 50 % set b a
a
(porrino) 51 % puts $b
a
(porrino) 52 % puts "[set $b]"
can't read "a": variable is array
(porrino) 53 % puts "[set $b](1)"
can't read "a": variable is array
(porrino) 54 % puts "[set $b(1)]"
can't read "b(1)": variable isn't array



Sat, 05 Jun 2004 22:36:12 GMT  
 accessing to a variable by ref (variable is an array)
sorry for the stupid question, i've used upvar and i've resolved the problem.
Thank you
Stefano


Sun, 06 Jun 2004 17:47:00 GMT  
 accessing to a variable by ref (variable is an array)

Quote:
> i try to access to an array named a, his name is stored in another
variable , b.
> how to do that?
> Thank you
> Stefano

> (porrino) 49 % set a(1) ciao
> ciao
> (porrino) 50 % set b a
> a
> (porrino) 51 % puts $b
> a
> (porrino) 52 % puts "[set $b]"
> can't read "a": variable is array
> (porrino) 53 % puts "[set $b](1)"
> can't read "a": variable is array
> (porrino) 54 % puts "[set $b(1)]"
> can't read "b(1)": variable isn't array

You missed one variation (the one that works :-)

puts [set ${b}(1)]



Mon, 07 Jun 2004 23:33:04 GMT  
 accessing to a variable by ref (variable is an array)
Thank you Bryan!
: )
ciao
Stefano


Tue, 08 Jun 2004 15:39:59 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. how to access arrays with variable for array names and index

2. access to array if name of array is variable

3. Local variables - lifetime and access variables [Q]

4. Accessing a variable of a variable

5. accessing a local variable in from a widgets -variable or -command properties

6. Help: Accessing Variables Within Variables

7. SUMMARY: Help: Accessing Variables Within Variables

8. array name in variable variable

9. TCL access to array variables

10. Class variables / global variables / Init variables

11. Ref. counting and class variables

12. Ref. counting and class variables

 

 
Powered by phpBB® Forum Software