The trace command registers a command to be called whenever a variable is accessed, modified, or unset. This form of the command is:
trace variable name ops command
The name is a Tcl variable name, which can be a simple variable, an array, or an array element. If a whole array is traced, the trace is invoked when any element is used according to ops. The ops argument is one or more of the letters r, for read traces, w, for write traces, and u, for unset traces. The command is executed when one of these events occurs. It is invoked as:
command name1 name2 op
The name1 argument is the variable or array name. The name2 argument is the name of the array index, or null if the trace is on a simple variable. If there is an ...