Given Data
array set color {a red b green c blue}
set keylist [array names $color]
pointlist {{1 2 3 4} {5 6 7 8} {9 10 11 12} {13 14 15 16}}
I get a new list after running a procedure.
newlist {b b b b} # Note: length of newlist is same as length of pointlist
Question is : when i run a loop these values of b should be substituted, for example in this green.
for {set i 0} { $i < [llength $pointlist]} {incr i } {
lassign [lindex $pointlist $i] x1 y1 x2 y2
APICommand -points "$x1,$y1,$x2,$y2" -color $color($keylist)
}
Now this $color($keylist) is not getting me correct result and errors out saying : can't read "color(red blue green)": no such element in array
Instead I want the first set of 4 points to get the green color which is the value of b. Similarly next set of 4 points from pointlist should also get green as its value is also b.
#So, after substitution it should look like APIcommand -points 1,2,3,4 -color green ..... so on and so forth
Note this will not always be b , it just happens to be in this case.
Need solution asap. Thanks in advance.