Debian Codegraph @

html/watch.html

raw symbols SCIP
1 <!-- manual page source format generated by PolyglotMan v3.0.8+XFree86, -->
2 <!-- available via anonymous ftp from ftp.cs.berkeley.edu:/ucb/people/phelps/tcltk/rman.tar.Z -->
3
4 <HTML>
5 <HEAD>
6 <TITLE>watch(n) manual page</TITLE>
7 </HEAD>
8 <BODY BGCOLOR="#efefef" TEXT="black" LINK="blue" VLINK="#551A8B" ALINK="red">
9 <A HREF="#toc">Table of Contents</A><P>
10
11 <H2><A NAME="sect0" HREF="#toc0">Name</A></H2>
12 watch - call Tcl procedures before and after each
13 command
14 <H2><A NAME="sect1" HREF="#toc1">Synopsis</A></H2>
15 <B>watch create</B> <I>watchName</I> ?<I>options</I>? <P>
16 <B>watch activate</B> <I>watchName</I>
17 <P>
18 <B>watch deactivate</B> <I>watchName</I> <P>
19 <B>watch delete</B> <I>watchName</I> <P>
20 <B>watch configure</B> <I>watchName</I>
21 ?<I>options</I> <P>
22 <B>watch info</B> <I>watchName</I> <P>
23 <B>watch names</B>
24 <H2><A NAME="sect2" HREF="#toc2">Description</A></H2>
25 The <B>watch</B> command
26 arranges for Tcl procedures to be invoked before and after the execution
27 of each Tcl command.
28 <H2><A NAME="sect3" HREF="#toc3">Introduction</A></H2>
29 When an error occurs in Tcl, the global
30 variable <I>errorInfo</I> will contain a stack-trace of the active procedures when
31 the error occured. Sometimes, however, the stack trace is insufficient.
32 You may need to know exactly where in the program's execution the error
33 occured. In cases like this, a more general tracing facility would be useful.
34 <P>
35 The <B>watch</B> command lets you designate Tcl procedures to be invoked before
36 and after the execution of each Tcl command. This means you can display
37 the command line and its results for each command as it executes. Another
38 use is to profile your Tcl commands. You can profile any Tcl command (like
39 <B>if</B> and <B>set</B>), not just Tcl procedures.
40 <H2><A NAME="sect4" HREF="#toc4">Example</A></H2>
41 The following example use <B>watch</B>
42 to trace Tcl commands (printing to standard error) both before and after
43 they are executed. <BR>
44 <CODE>proc preCmd { level command argv } {<BR>
45 set name [lindex $argv 0]<BR>
46 puts stderr "$level $name =&gt; $command"<BR>
47 }<BR>
48 <P>
49 proc postCmd { level command argv retcode results } {<BR>
50 set name [lindex $argv 0]<BR>
51 puts stderr "$level $name =&gt; $argv0= ($retcode) $results"<BR>
52 }<BR>
53 watch create trace \<BR>
54 <tt>&#32;</tt>&nbsp;<tt>&#32;</tt>&nbsp;-postcmd postCmd -precmd preCmd<BR>
55
56 <H2><A NAME="sect5" HREF="#toc5"></CODE><P>Operations</A></H2>
57 The following operations are available for the <B>watch</B> command:
58
59 <DL>
60
61 <DT><B>watch activate <I>watchName</I></B> </DT>
62 <DD>Activates the watch, causing Tcl commands the
63 be traced to the maximum depth selected. </DD>
64
65 <DT><B>watch create <I>watchName</I></B> ?<I>options</I>?...
66 </DT>
67 <DD>Creates a new watch <I>watchName</I>. It's an error if another watch <I>watchName</I>
68 already exists and an error message will be returned. <I>Options</I> may have any
69 of the values accepted by the <B>watch configure</B> command. This command returns
70 the empty string. </DD>
71
72 <DT><B>watch configure <I>watchName</I></B> ?<I>options...</I>? </DT>
73 <DD>Queries or modifies
74 the configuration options of the watch <I>watchName</I>. <I>WatchName</I> is the name
75 of a watch. <I>Options</I> may have any of the following values: <blockquote></DD>
76
77 <DT><B>-active <I>boolean</I></B>
78 </DT>
79 <DD>Specifies if the watch is active. By default, watches are active when created.
80 </DD>
81
82 <DT><B>-postcmd <I>string</I></B> </DT>
83 <DD>Specifies a Tcl procedure to be called immediately after
84 each Tcl command. <I>String</I> is name of a Tcl procedure and any extra arguments
85 to be passed to it. Before <I>string</I> is invoked, five more arguments are appended:
86 1) the current level 2) the current command line 3) a list containing the
87 command after substitutions and split into words 4) the return code of
88 the command, and 5) the results of the command. The return status of the
89 postcmd procedure is always ignored. </DD>
90
91 <DT><B>-precmd <I>string</I></B> </DT>
92 <DD>Specifies a Tcl procedure
93 to be called immediately before each Tcl command. <I>String</I> is name of a Tcl
94 procedure and any extra arguments to be passed to it. Before <I>string</I> is
95 invoked, three arguments are appended: 1) the current level 2) the current
96 command line, and 3) a list containing the command after substitutions
97 and split into words. The return status of the <B>-precmd</B> procedure is always
98 ignored. </DD>
99
100 <DT><B>-maxlevel <I>number</I></B> </DT>
101 <DD>Specifies the maximum evaluation depth to watch
102 Tcl commands. The default maximum level is 10000. </DD>
103 </DL>
104 </blockquote>
105
106 <DL>
107
108 <DT><B>watch deactivate <I>watchName</I></B>
109 </DT>
110 <DD>Deactivates the watch. The <B>-precmd</B> and <B>-postcmd</B> procedures will no longer
111 be invoked. </DD>
112
113 <DT><B>watch info <I>watchName</I></B> </DT>
114 <DD>Returns the configuration information
115 associated with the watch <I>watchName</I>. <I>WatchName</I> is the name of a watch.
116 </DD>
117
118 <DT><B>watch names</B> ?<I>state</I>? </DT>
119 <DD>Lists the names of the watches for a given state. <I>State</I>
120 may be one of the following: <I>active</I>, <I>idle</I>, or <I>ignore</I>. If a <I>state</I> argument
121 isn't specified, all watches are<BR>
122 listed. </DD>
123 </DL>
124 </blockquote>
125
126 <H2><A NAME="sect6" HREF="#toc6">Keywords</A></H2>
127 debug, profile <P>
128
129 <HR><P>
130 <A NAME="toc"><B>Table of Contents</B></A><P>
131 <UL>
132 <LI><A NAME="toc0" HREF="#sect0">Name</A></LI>
133 <LI><A NAME="toc1" HREF="#sect1">Synopsis</A></LI>
134 <LI><A NAME="toc2" HREF="#sect2">Description</A></LI>
135 <LI><A NAME="toc3" HREF="#sect3">Introduction</A></LI>
136 <LI><A NAME="toc4" HREF="#sect4">Example</A></LI>
137 <LI><A NAME="toc5" HREF="#sect5">Operations</A></LI>
138 <LI><A NAME="toc6" HREF="#sect6">Keywords</A></LI>
139 </UL>
140 </BODY></HTML>