stdout redirection

If you are using Tcl 8.6, you can trap all the output to stdout by adding a suitable transform via chan push: # Use a class to simplify the capture code oo::class create CapturingTransform { variable var constructor {varName} { # Make an alias from the instance variable to the global variable my eval [list … Read more

Why do Tcler suggest to brace your `expr`essions?

The “problem” with expr is that it implements its own “mini language”, which includes, among other things, variable substitution (replacing those $a-s with their values) and command substitution (replacing those [command …] things with the results of running commands), so basically the process of evaluating expr $a + $b goes like this: The Tcl interpreter … Read more

TCL can’t find mistake [closed]

There are several problems with your script. The first of which is on the first line: set QA1 array() This doesn’t do what you think it does. What it does is create a scalar variable (not an array) that contains the seven character string “array()”. Later you try to access it as an array: set … Read more