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?

有帮助吗?

解决方案

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"
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top