I am trying to run a procedure that takes an array called ds_out, changes values of ds_out(0) and ds(1) to either 0 or 1 depending on the state of a checkbox and returns it. I want to then output the values after the procedure but it looks like the procedure is not returning the array and printing the values in the initialising array. If you have the puts lines in the procedure it works.
I've looked at tutorials and examples but I don't understand them. I want the basic of basic examples but can't find them.
Below is the code I have used:
global ds_out
array set ds_out {
0 0
1 0
}
proc kl15cb {} {
checkbutton .kl15_cb -width 10 -height 1 -text "check me" -variable kl15_cb -command {if {$kl15_cb} {
set ds_out(0) 0
set ds_out(1) 0
pack .kl15_cb
} else {
set ds_out(0) 1
set ds_out(1) 1
pack .kl15_cb
return [array get ds_out]
} } }
kl15cb
puts $ds_out(0)
puts $ds_out(1)
pack .kl15_cb
ds_outis never used in the procedure's local scope, only globally within the callback script.