user interface - tk_optionMenu error "can't read "a": no such variable" -


i trying execute simple code

global eval tk_optionmenu .qt.oc  [list 1 2 4 8 16] proc run {} {     puts "$a" } 

i have button associated run proc , when press pres on run button receive following error:

can't read "a": no such variable can't read "a": no such variable     while executing "puts "$a""     (procedure "run" line 2)     invoked within "run"     invoked within ".top.run invoke"     ("uplevel" body line 1)     invoked within "uplevel #0 [list $w invoke]"     (procedure "tk::buttonup" line 22)     invoked within "tk::buttonup .top.run"     (command bound event) 

any suggestions?

global must used inside scope trying access global variable. example:

proc run {} {     global     puts "$a" } 

here's excerpt global man page:

this command has no effect unless executed in context of proc body.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -