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!

Acess variables with "variable" names

Status
Not open for further replies.

lemmans

Technical User
Aug 2, 2007
2
ES
Hi everyone:

Here is my problem:

I generate variables of the type: a1 a2 a3...a"n"
I do it in a "for" loop

The problem is when I want to access to the values contained in this variables (again in another "for" loop):

I can't access to its values using $a$i (been "i" another varible that its changing in the loop) because it says that $a doesn't exists. Off course it doesn't exists , I want to access a1 a2...an

I've tried with $a($i) and similar things, but I don't find the way.

I'm new programming in TCL.


If someone can help I'll be very thankful.



 
Hi

Code:
[gray]# set[/gray]
[b]for[/b] {[b]set[/b] i 0} {$i<3} {[b]incr[/b] i} { [b]set[/b] a$i [i]"this is $i value"[/i] }

[gray]# retrieve[/gray]
[b]for[/b] {[b]set[/b] i 0} {$i<3} {[b]incr[/b] i} { [b]puts[/b] [[b]set[/b] a$i] }

Feherke.
 
Thanks a lot I finally finished the program.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top