BrianLeighton
Programmer
I'm new to TCL and have been trying like crazy to output the value of a certain index in a defined array. The trick is that the array name changes. I have several arrays, named STATS0, STATS1, STATS2,...STATx..and so on. I thought I could just set up a loop to increment the name (i.e STATS$x) and read the index. Here's what I've got so far...
}
proc writestats {OutputFile CellRate ShowIdle ChannelCount} {
puts $OutputFile $CellRate
for {set x 0} {$x<$ChannelCount} {incr x} {
global STATS$x ; #works fine
parray "STATS$x" ; #works but prints the whole array
puts $STATS0(-VPI) ;#works but don't increment obviously
# puts STATS$x(-VPI) error - don't work
# puts $STATS$x(-VPI) error - don't work
# puts [STATS$x](-VPI) error - don't work
# puts $[STATS$x](-VPI) error - don't work
# puts (STATS$x)(-VPI) error - don't work
# puts /$STATS$x(-VPI) error - don't work
Any ideas on how I need to format my syntax to make it work?
Thanks!
}
proc writestats {OutputFile CellRate ShowIdle ChannelCount} {
puts $OutputFile $CellRate
for {set x 0} {$x<$ChannelCount} {incr x} {
global STATS$x ; #works fine
parray "STATS$x" ; #works but prints the whole array
puts $STATS0(-VPI) ;#works but don't increment obviously
# puts STATS$x(-VPI) error - don't work
# puts $STATS$x(-VPI) error - don't work
# puts [STATS$x](-VPI) error - don't work
# puts $[STATS$x](-VPI) error - don't work
# puts (STATS$x)(-VPI) error - don't work
# puts /$STATS$x(-VPI) error - don't work
Any ideas on how I need to format my syntax to make it work?
Thanks!