Getting feedback on execution stages and the values of specific variables
The 'puts' command is probably the most ubiquitous debugging tool used by Tcl coders. Sure there are more complex and elaborate ways of watching the execution process and the Tcler's wiki gives a lots of good tips in this area. For me, the simpler the better. Here's a short, utility proc that I've been using recently.
The procedure below illustrates how it can be used:
The first call to _S_ simply returns the name 'myproc' and any arguments passed to it. But, as can be seen in the definition of _S_ it can take two arguments: i which defaults to an empty string, and args which, of course, is the standard Tcl expression for a list of args. Its necessary to have the first argument i, even if nothing is passed, as args alone will throw an up error. So, '_S_ 1' in the script denotes stage one, in the process. It will result in the name of the procedure, ie myProc being printed to stdout along with the stage reference, ie 1.
Reading through the remainder of the sample shows how the extras can be passed.
Gnocl Cookbook >