Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable name - tk

Status
Not open for further replies.

ee1

Programmer
May 31, 2011
25
0
0
IL
Hi,
suppuse i have some varialbes: foo, bar, aaa.
each varialbe has a value.

and i send to a proc the var name as a string.
how can i get the var value?

for example:
proc {var_name} {

}
i would like to be able to get the value of the variable.
if i send "foo"
i want to see the value of foo ($foo).

i tried: $$var_name, $(var_name), $"$var_name"
but nothing worked...

thanks.
 
Hi

Use [tt]set[/tt] :
Code:
[b]proc[/b] some_proc [teal]{[/teal]var_name[teal]}[/teal] [teal]\[/teal]
[teal]{[/teal]
  [b]global[/b] [navy]$var_name[/navy]
  [b]puts[/b] [green][i]"$var_name's value is [ set $var_name ]"[/i][/green]
[teal]}[/teal]

[b]set[/b] some_var [green][i]"some value"[/i][/green]

some_proc some_var

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top