watch(n)
π watch(n) β BLT Built-In Commands π
okay bestie, this is the whole watch manual: the Tcl tracing baddie that calls procedures before and after every command. no cap. π
π NAME π
watch β call Tcl procedures before and after each command.
β¨ SYNOPSIS β¨
watch create watchName ?options?
watch activate watchName
watch deactivate watchName
watch delete watchName
watch configure watchName ?options
watch info watchName
watch names
π¦ DESCRIPTION π¦
The watch command arranges for Tcl procedures to be invoked before and after the execution of each Tcl command. literally its whole job. π
πΈ INTRODUCTION πΈ
When an error occurs in Tcl, the global variable errorInfo will contain a stack-trace of the active procedures when the error occurred. sometimes that stack trace is just not enough, bestie. π
You may need to know exactly where in the program's execution the error occurred. In cases like this, a more general tracing facility would be useful.
The watch command lets you designate Tcl procedures to be invoked before and after the execution of each Tcl command. This means you can display the command line and its results for each command as it executes. Another use is to profile your Tcl commands. You can profile any Tcl command (like if and set), not just Tcl procedures. slay. β¨
π₯ EXAMPLE π₯
The following example use watch to trace Tcl commands (printing to standard error) both before and after they are executed.
proc preCmd { level command argv } {
set name [lindex $argv 0]
puts stderr "$level $name => $command"
}
proc postCmd { level command argv retcode results } {
set name [lindex $argv 0]
puts stderr "$level $name => $argv0= ($retcode) $results"
}
watch create trace \
-postcmd postCmd -precmd preCmd
π OPERATIONS π
The following operations are available for the watch command:
π οΈ watch activate watchName
Activates the watch, causing Tcl commands to be traced to the maximum depth selected. π
π οΈ watch create watchName ?options?...
Creates a new watch watchName. It's an error if another watch watchName already exists and an error message will be returned. Options may have any of the values accepted by the watch configure command. This command returns the empty string. cute and simple. π
π οΈ watch configure watchName ?options...?
Queries or modifies the configuration options of the watch watchName. watchName is the name of a watch. Options may have any of the following values:
-activebooleanβ Specifies if the watch is active. By default, watches are active when created. π-postcmdstringβ Specifies a Tcl procedure to be called immediately after each Tcl command.stringis name of a Tcl procedure and any extra arguments to be passed to it. Beforestringis invoked, five more arguments are appended: 1) the current level 2) the current command line 3) a list containing the command after substitutions and split into words 4) the return code of the command, and 5) the results of the command. The return status of thepostcmdprocedure is always ignored. π-precmdstringβ Specifies a Tcl procedure to be called immediately before each Tcl command.stringis name of a Tcl procedure and any extra arguments to be passed to it. Beforestringis invoked, three arguments are appended: 1) the current level 2) the current command line, and 3) a list containing the command after substitutions and split into words. The return status of the-precmdprocedure is always ignored. π«-maxlevelnumberβ Specifies the maximum evaluation depth to watch Tcl commands. The default maximum level is10000. highkey deep. π
π οΈ watch deactivate watchName
Deactivates the watch. The -precmd and -postcmd procedures will no longer be invoked. bye bestie π
π οΈ watch info watchName
Returns the configuration information associated with the watch watchName. watchName is the name of a watch. π«Ά
π οΈ watch names ?state?
Lists the names of the watches for a given state. state may be one of the following: active, idle, or ignore. If a state argument isn't specified, all watches are listed. bestie filter. π
π KEYWORDS π
debug, profile
β source/version: BLT 2.5 Β· page: watch(n) Β· date: the footer doesn't give one, so I'm not making one up β periodt. π
π¦ where this page comes from
- nixpkgs unstable: blt 2.5.3
- Copyright 1991-1997 by Bell Labs Innovations for Lucent Technologies
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms