Reputation: 8931
I want to make several objects, all with the same parameters, so I tried to store them in a proc that returns them. But the interpreter evaluates the returning result as one parameter, instead of several. my proc is:
proc element_param {} {
return "-filled 1\
-visible 1\
-linewidth 1\
-linecolor yellow\
-fillcolor yellow\
-relief roundraised\
-linewidth 2"
}
and I use it with:
$this/zinc add rectangle 1 [list "100" "100" "200" "200"] [element_param]
How do I turn them into several different parameters?
Upvotes: 1
Views: 163
Reputation: 33193
With tcl 8.5 and above use the {*} operator to expand the list of parameters:
$this/zinc add rectangle 1 $coords {*}[element_param]
with previous versions you can expand lists using eval:
eval [linsert [element_param] 0 $this/zinc add rectangle 1 $coords]
which is equivalent.
Upvotes: 7