I have a problem passing variables on the command option, for example:
package require Tk
wm withdraw .
destroy .button
toplevel .button
# button.0: puts 0
set count 0
button .button.$count -text $count -command {puts $count}
grid .button.$count -column $count -row 0
# button.1: puts 1
incr count
button .button.$count -text $count -command {puts $count}
grid .button.$count -column $count -row 0
However button.0 puts 1 instead of 0. It seems when the button.0 is called it takes the value of the variable at that moment which is 1.
I figure it out that I can use a procedure and a global variable to achieve the desire results, but I would like to know if it is possible to achieve this without resorting to a procedure call.
Thank you in advance.