Re: Getting proc to recognize all global variables

From: Glenn Jackman (xx087_at_freenet.carleton.ca)
Date: 02/12/04


Date: 12 Feb 2004 15:10:35 GMT

David McClamrock <mcclamrock@locl.net> wrote:
> Would somebody please remind me how (or whether) it's possible to get a proc
> to recognize all variables in the global scope, even if the variables
> aren't mentioned by name in the proc itself? If so, thanks in advance!

    proc inGlobalScope {} {
        uplevel #0 {
            # this is the proc body
            # with global vars
        }
    }

have some care about variables in different scopes though:

    proc inglobal {x} {
        puts $x
        uplevel #0 {puts $x}
    }
    set x fred
    inglobal joe

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


Relevant Pages