Re: How can I pass variable throught "-command"



* Arndt Roger Schneider <roger.schneider@xxxxxxxxx>
| i've used both; right-now i do prefer subst:
|
| scrollbar $cur_win1.sb1 -command [subst {$cur_win1.txt2 yview}]

Makes the reviewer wonder `why doesn't he use the standard idiom'?

Again, if $cur_win1 should contain special charcters, this will fail.
set cur_win1 {.foo bar}
toplevel $cur_win1
text $cur_win1.txt2
scrollbar $cur_win1.sb1 -command [subst {$cur_win1.txt2 yview}]
pack $cur_win1.txt2 $cur_win1.sb1

Invoking the scrollbar gives you
ambiguous command name ".foo": {.foo bar} {.foo bar.sb1} {.foo bar.txt2}
while executing
".foo bar.txt2 yview -1"
("uplevel" body line 1)
invoked from within

Pray that nobody names their widgets
set cur_win1 {.foo [exec rm -f $::env(HOME)]}

When using 'list', all this is a non-issue.

R'
.



Relevant Pages