I did not look at this closely enough. I note you are trying to echo out all of the global values. There are things to consider.
1. Unless you are execting in the global scope, e.g., hcitcl, you must either declare the name as global or use the full global namespace path like ::globname.
2. Some of the globals are arrays and will cause a Tcl error if not accessed as such
3. Simply becuse a name is global does not make it exist. It must be set to something before it exists. It would be a Tcl error to access it if it does not exist.
So I offer up the following which will work in or out of the global scope, for example inside a proc. You must be aware that to echo all of the global variables will generate a *LOT* of data
foreach glob [info globals] {
global $glob
# Is it an array?
if {[array exists $glob]} {
echo nThe values of global array $glob are:
parray $glob
continue
}
# It is not an array, make sure it exists
if {[info exists $glob]} {
echo nThe value of global variable $glob is: [set $glob]
} else {
echo nThe value of global variable $glob is: UNDEFINED
}
}