In Tcl, I assigned values to numbered variables in a loop. how can I call these variables in another loop
for {set colNum 1} {$colNum < 37} {incr colNum} {
set Col$colNum 0
}
for {set colNum 1} {$colNum < 37} {incr colNum} {
puts "$Col$colNum"
}
If they are in the same namespace, then you can use
set
in this way:Usually though, you may want to avoid doing it that way and use
array
s instead:Or use
upvar
to create an alias (I'm usingupvar
to the global namespace,#0
, in the below example):