Question

I know that in a normal tcl script environment variables can be accessed like this:

global env
puts "User: $env(USER)"

set env(IOFILE) "somefile.txt"

but this doesn't seem to work within an ITCL class method. How can I get and set environment variables inside ITCL class code?

Était-ce utile?

La solution

Itcl does complex things with variable discovery, but you can override the trickiness by giving the fully-qualified name of the variable (the global command will bind the last component of the name in the local scope to the named variable). Thus:

global ::env  ;# <<<<<< Note this <<<<<<

puts "User: $env(USER)"
set env(FOO) "bar"
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top