*
universalde...@gmail.com
| Would you be able to provide some sample code which uses the global command?
Did you look at:
| >
https://www.tcl.tk/man/tcl/TclCmd/global.htm
? There are code snippets in there.
In short:
# set variable outside of any proc (i.e. global namespace)
set some_global_variable 1
# play it safe: explicitely specify global namespace
# set ::some_global_variable 1
proc this_does_not_work {} {
# error: variable is addressed in local scope where it does not exist
puts "the value is $some_global_variable"
}
# using 'global' command
proc this_does_work_1 {} {
global some_global_variable
# ok: variable is declared as global
puts "the value is $some_global_variable"
}
# using explicit namespace
proc this_does_work_2 {} {
# ok: variable is addressed in global namespace
puts "the value is $::some_global_variable"
}
Calling them:
% this_does_not_work
can't read "some_global_variable": no such variable
% this_does_work_1
the value is 1
% this_does_work_2
the value is 1
HTH
R'