List of Array tcl -
i have 5 arrays , want iterate on them 1 one, i'm thinking add these arrays array , access them 1 one indexes
array set listofarrays {1 $array1 2 $array2 3 $array3 4 $array4 5 $array5} { set 1} { $i <= 5 } {incr i} { set list $listofarrays($i) foreach {key} [array names list] { puts $key } }
the output empty...
what wrong?!
tcl's arrays can't put in list; they're (collections of) variables, not values. can put names of arrays in.
array set listofarrays {1 array1 2 array2 3 array3 4 array4 5 array5} { set 1} { $i <= 5 } {incr i} { upvar 0 $listofarrays($i) list foreach {key} [array names list] { puts $key } }
the upvar 0
? makes local alias variable, , it's great sort of thing.
Comments
Post a Comment