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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using contents of variable as part of variable name 2

Status
Not open for further replies.

Breadcrust

Programmer
Oct 27, 2003
42
AU
i want to do some thing like this:

set configcmd ${taskman_${taskman}_${task}_configcmd}

but as you can see that wont work, how can i do this so it will work?

ps - i know there is better ways to impliment this with arrys but im not interested in that right now


[tt]
Breadcrust (aka J@red)

Web - E-mail - net-head@softhome.net
Linux Reg. Number - 307180 ([/tt]
 
Look at subst.
Code:
[subst -novariable]
for instance.
 
To do that, you need an extra round of Tcl evaluation.
As marsd said,
Code:
subst
is just for that.
You can also get an extra round by using set:
Code:
  set configcmd [set taskman_${taskman}_${task}_configcmd]
([set var] takes a variable name and returns the variable value)

The Tcl evaluation mechanism is described here: (ref [1]).

But really, you seem to need arrays (building variables name is a true signal for that).
What about
Code:
::taskman($taskman.$task.configcmd)
?
(note the :: to have a global reference and avoid all array-arguments burden)

HTH

ulis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top