values of variable variable-names 
Author Message
 values of variable variable-names

Hi there,

can anybody tell me, how to access the values of variable variable
names?
For explanation:
I have a variable, which contains the name of another variable and want
to access the value of the second.
Is there somthing like $($name) ?

Thanks



Fri, 01 Nov 2002 03:00:00 GMT  
 values of variable variable-names


Quote:
>Hi there,

>can anybody tell me, how to access the values of variable variable
>names?
>For explanation:
>I have a variable, which contains the name of another variable and want
>to access the value of the second.
>Is there somthing like $($name) ?

                        .
                        .
                        .
<URL:http://starbase.neosoft.com/~claird/comp.lang.tcl/tcl_deref.html>
--


Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html



Fri, 01 Nov 2002 03:00:00 GMT  
 values of variable variable-names

Quote:

> Hi there,

> can anybody tell me, how to access the values of variable variable
> names?
> For explanation:
> I have a variable, which contains the name of another variable and want
> to access the value of the second.
> Is there somthing like $($name) ?

> Thanks

set varname var
set var 1
puts [set $varname]


Fri, 01 Nov 2002 03:00:00 GMT  
 values of variable variable-names


Quote:

>> can anybody tell me, how to access the values of variable variable
>> names?

> set varname var
> set var 1
> puts [set $varname]

Or (some variation on):
  upvar 0 $varname someAlias; puts $someAlias

Often it is acutally better to use arrays or something based on
namespaces; it depends on what you are really seeking to do, and Tcl
has many ways to do what you want...

Donal.
--

-- I may seem more arrogant, but I think that's just because you didn't
   realize how arrogant I was before.  :^)



Sun, 03 Nov 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using a variable name for a variable name??

2. treat value in a variable as a variable

3. variable contents to variable name

4. array name in variable variable

5. getting variable name from the variable itself?

6. Variables containing variable names

7. name of a variable stored in another variable

8. Variable variable names?

9. (SETF (#'named-function variable) value)

10. How to write a macro for printing variable's name and its value

11. Class variables / global variables / Init variables

12. value of value of a variable ?

 

 
Powered by phpBB® Forum Software