Anyone got any suggestions where to look? Did a google search and got the following:
a plain puts raises the error
cannot find channel named “stdout”
But as puts is a frequent and useful command, we want to have it working. So here’s a substitute that redirects the output to a specified text widget, if the (implicit or explicit) channel name is stdout or stderr, but else calls the original puts, which was renamed into the ::tcl namespace: }
proc redef_puts w {
set ::putsw $w
if ![llength [info command ::tcl::puts]] {
rename puts ::tcl::puts
proc puts args {
set la [llength $args]
if {$la<1 || $la>3} {
error “usage: puts ?-nonewline? ?channel? string”
}
set nl n
if {[lindex $args 0]==”-nonewline”} {
set nl “”
set args [lrange $args 1 end]
}
if {[llength $args]==1} {
set args
] ;# (2)
}
foreach {channel s} $args break
#set s [join $s] ;# (1) prevent braces at leading/tailing spaces
if {$channel==”stdout” || $channel==”stderr”} {
$::putsw insert end $s$nl
} else {
set cmd ::tcl::puts
if {$nl==””} {lappend cmd -nonewline}
lappend cmd $channel $s
eval $cmd
}
}
}
}