I used to keep this stuff off this group, but since the main TCL/tk group has been killed,
there's no obvious group to go to. Somebody with enough TCL/tk knowledge might be able to solve this one.
This program reads a TCL/tk command from a file. For example:
button .b eot
The eot (end of transmission) shows the command is ready to be executed. The function newcommand? tests the file for a new command
proc newcommand? {File} {
set Source [open $File r]
set Data [read $Source]
set Verdict [eot? $Data]
close $Source
return $Verdict}
proc eot? {S} {
return [ string match *eot $S ]
}
So I put
button .b eot into the file which is called in in the program. I ask TCL if there is a new command waiting.
(bin) 23 % newcommand? $in
1
TCL/tk says yes. I then tell TCL to enact what is in this file.
proc enact {File} {
set Source [open $File r]
set Data [read $Source]
set Command [trim $Data]
overwrite $File
eval $Command
close $Source}
trim just trims the eot off the file contents. So I enter enact $in. The contents are eaten and the in file is now empty. If I then submit
pack .b eot
in the same way; sure enough the button appears in WISH. Now I enter
set myvar 1
and enact that. But if I then enter
puts $myvar
I get
can't read "myvar": no such variable
Mark