NAME
global - Access global variables
SYNOPSIS
global varname ?varname ...?
DESCRIPTION
This command is ignored unless a Tcl procedure is being interpreted. If so then it declares the given varname's to be global variables rather than local ones. For the duration of the current procedure (and only while executing in the current procedure), any reference to any of the varnames will refer to the global variable by the same name.
Global variables are found with respect to the current namespace context. To access global variables in another namespace, simply include namespace qualifiers in the var- name arguments. For example,
set x "ignored"
set y 1
namespace foo {
variable x 0
variable y "ignored"
proc checkx {} {
global x
return $x
}
proc checky {} {
global ::y
return $y
}
}
The command "foo::checkx" will return the value of "foo::x" which is "0". The command "foo::checky" will return the value of "::y" which is "1".
KEYWORDS
global, procedure, variable