- This topic has 3 replies, 3 voices, and was last updated 18 years, 5 months ago by .
-
Topic
-
I am try to reference a variable variable name.. that is, the varName is not always the same, but it needs to be referenced by $varName. Specifically, array names. So for the following code, I have a varName set of “threadList”, and it is a list equal to “thread1 thread2 thread3”
I have two arrays defined, each one has 5 identically named elements. The array names are thread1, and thread3
tcl> array names thread1
recBSnd recNSnd recTime recBRec recNRec recSite
tcl> array names thread3
recBSnd recNSnd recTime recBRec recNRec recSite
tcl> puts $threadList
thread1 thread2 thread3
Code:foreach thrd $threadList {
if {[info exists $thrd]} {
append $sep $thrd(recBSnd) $sep $thrd(recBRec)
}
}
My problem is arrays have to be referenced via the array name. The array name (for the first run through) is “thread1”.
puts $thread1(recBSnd)
returns a value. But I don’t know how to reference the array name by using a variable name.
Any help would be appreciated.
Thanks
Todd
- The forum ‘Cloverleaf’ is closed to new topics and replies.