On Fri, 14 Feb 1997 [EMAIL PROTECTED] wrote:

> I do a save.
> 
> In vtcl I can look in  the Variable list and see  the variable var1. 
> In  the  toplevel  code it says  
> global var1;  var1='grow'           # note that welch says that a global
> at the top level does nothing.  p52 ?
> 
> But, there's not a global statement in the procedure;
> 
> proc  vTclWindow.top17
> 
> which holds that actual buttons,  so this global variable and the
> variable in the  vTclWindow
> procedure are  not really the same variable (true?)

 Any code contained within the -command {} option of a button is
 in the global scope, not the scope of the containing procedure.

> So, If I now go into init or some other  procedure and try to acess the
> global variable 
> var1, (ie   global var1;  puts stdout var1)  it doesn't see the
> value  set by the checkbuttons.  

 That's odd. Take a look at this example:

---
        global x; set x BBB

        proc scopetest {} {
                global x
                puts "x initially set to: $x"
        }

        proc scopetest2 {} {
                radiobutton .a -text AAA -variable x -value AAA
                radiobutton .b -text BBB -variable x -value BBB

                button .c -text "Print" -command {puts $x}

                pack .a .b .c
        }

        scopetest
        scopetest2
---

 note that x shows up in scopetest and in the command section of
 the button even though it is not declared global in scopetest2.

 hope this helps,

 -stewart "catching up on old mail" allen-

Reply via email to