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

working with variables

Status
Not open for further replies.

pankajpanjwani

Technical User
Mar 25, 2002
24
EU
Hi Experts,
I have a code like

set abc 1
set def 1
set xyz 0
...
...

foreach x { abc def xyz } {
if { <value of variable $x> != 0} {
perform this
} else {
perform this
}
}

In this by <value of variable $x> I mean that I would like to have value 0 or 1, depending upon variable &quot;abc&quot;/&quot;def&quot;/&quot;xyz&quot;

I am unable to make TCL subsitutue the value of variable in the &quot;if&quot; condition.

Do you have any solution for this.
thanks for reading and problem and thinking on problem.

Rgds
Pankaj
 
Code:
  set abc 1
  set def 2
  set ghi 3
  foreach v {abc def ghi} { puts [set $v] }

An other way:
Code:
eval puts $v
but eval is not easy to master so the first way is better.

Good luck!

ulis
 
thanks ulis,
This worked, I tried almost evrything except this
Anyways, thanks and your right eval looks to be simple but it's more complex to master.

Pankaj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top