1 |
578 |
markom |
'\"
|
2 |
|
|
'\" Copyright (c) 1993 The Regents of the University of California.
|
3 |
|
|
'\" Copyright (c) 1994-1997 Sun Microsystems, Inc.
|
4 |
|
|
'\"
|
5 |
|
|
'\" See the file "license.terms" for information on usage and redistribution
|
6 |
|
|
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
7 |
|
|
'\"
|
8 |
|
|
'\" RCS: @(#) $Id: tclvars.n,v 1.1.1.1 2002-01-16 10:25:25 markom Exp $
|
9 |
|
|
'\"
|
10 |
|
|
.so man.macros
|
11 |
|
|
.TH tclvars n 8.0 Tcl "Tcl Built-In Commands"
|
12 |
|
|
.BS
|
13 |
|
|
'\" Note: do not modify the .SH NAME line immediately below!
|
14 |
|
|
.SH NAME
|
15 |
|
|
tclvars \- Variables used by Tcl
|
16 |
|
|
.BE
|
17 |
|
|
|
18 |
|
|
.SH DESCRIPTION
|
19 |
|
|
.PP
|
20 |
|
|
The following global variables are created and managed automatically
|
21 |
|
|
by the Tcl library. Except where noted below, these variables should
|
22 |
|
|
normally be treated as read-only by application-specific code and by users.
|
23 |
|
|
.TP
|
24 |
|
|
\fBenv\fR
|
25 |
|
|
This variable is maintained by Tcl as an array
|
26 |
|
|
whose elements are the environment variables for the process.
|
27 |
|
|
Reading an element will return the value of the corresponding
|
28 |
|
|
environment variable.
|
29 |
|
|
Setting an element of the array will modify the corresponding
|
30 |
|
|
environment variable or create a new one if it doesn't already
|
31 |
|
|
exist.
|
32 |
|
|
Unsetting an element of \fBenv\fR will remove the corresponding
|
33 |
|
|
environment variable.
|
34 |
|
|
Changes to the \fBenv\fR array will affect the environment
|
35 |
|
|
passed to children by commands like \fBexec\fR.
|
36 |
|
|
If the entire \fBenv\fR array is unset then Tcl will stop
|
37 |
|
|
monitoring \fBenv\fR accesses and will not update environment
|
38 |
|
|
variables.
|
39 |
|
|
.RS
|
40 |
|
|
.VS 8.0
|
41 |
|
|
Under Windows, the environment variables PATH and COMSPEC in any
|
42 |
|
|
capitalization are converted automatically to upper case. For instance, the
|
43 |
|
|
PATH variable could be exported by the operating system as ``path'',
|
44 |
|
|
``Path'', ``PaTh'', etc., causing otherwise simple Tcl code to have to
|
45 |
|
|
support many special cases. All other environment variables inherited by
|
46 |
|
|
Tcl are left unmodified.
|
47 |
|
|
.VE
|
48 |
|
|
.RE
|
49 |
|
|
.RS
|
50 |
|
|
On the Macintosh, the environment variable is constructed by Tcl as no
|
51 |
|
|
global environment variable exists. The environment variables that
|
52 |
|
|
are created for Tcl include:
|
53 |
|
|
.TP
|
54 |
|
|
\fBLOGIN\fR
|
55 |
|
|
This holds the Chooser name of the Macintosh.
|
56 |
|
|
.TP
|
57 |
|
|
\fBUSER\fR
|
58 |
|
|
This also holds the Chooser name of the Macintosh.
|
59 |
|
|
.TP
|
60 |
|
|
\fBSYS_FOLDER\fR
|
61 |
|
|
The path to the system directory.
|
62 |
|
|
.TP
|
63 |
|
|
\fBAPPLE_M_FOLDER\fR
|
64 |
|
|
The path to the Apple Menu directory.
|
65 |
|
|
.TP
|
66 |
|
|
\fBCP_FOLDER\fR
|
67 |
|
|
The path to the control panels directory.
|
68 |
|
|
.TP
|
69 |
|
|
\fBDESK_FOLDER\fR
|
70 |
|
|
The path to the desk top directory.
|
71 |
|
|
.TP
|
72 |
|
|
\fBEXT_FOLDER\fR
|
73 |
|
|
The path to the system extensions directory.
|
74 |
|
|
.TP
|
75 |
|
|
\fBPREF_FOLDER\fR
|
76 |
|
|
The path to the preferences directory.
|
77 |
|
|
.TP
|
78 |
|
|
\fBPRINT_MON_FOLDER\fR
|
79 |
|
|
The path to the print monitor directory.
|
80 |
|
|
.TP
|
81 |
|
|
\fBSHARED_TRASH_FOLDER\fR
|
82 |
|
|
The path to the network trash directory.
|
83 |
|
|
.TP
|
84 |
|
|
\fBTRASH_FOLDER\fR
|
85 |
|
|
The path to the trash directory.
|
86 |
|
|
.TP
|
87 |
|
|
\fBSTART_UP_FOLDER\fR
|
88 |
|
|
The path to the start up directory.
|
89 |
|
|
.TP
|
90 |
|
|
\fBPWD\fR
|
91 |
|
|
The path to the application's default directory.
|
92 |
|
|
.PP
|
93 |
|
|
You can also create your own environment variables for the Macintosh.
|
94 |
|
|
A file named \fITcl Environment Variables\fR may be placed in the
|
95 |
|
|
preferences folder in the Mac system folder. Each line of this file
|
96 |
|
|
should be of the form \fIVAR_NAME=var_data\fR.
|
97 |
|
|
.PP
|
98 |
|
|
The last alternative is to place environment variables in a 'STR#'
|
99 |
|
|
resource named \fITcl Environment Variables\fR of the application. This
|
100 |
|
|
is considered a little more ``Mac like'' than a Unix style Environment
|
101 |
|
|
Variable file. Each entry in the 'STR#' resource has the same format
|
102 |
|
|
as above. The source code file \fItclMacEnv.c\fR contains the
|
103 |
|
|
implementation of the env mechanisms. This file contains many
|
104 |
|
|
#define's that allow customization of the env mechanisms to fit your
|
105 |
|
|
applications needs.
|
106 |
|
|
.RE
|
107 |
|
|
.TP
|
108 |
|
|
\fBerrorCode\fR
|
109 |
|
|
After an error has occurred, this variable will be set to hold
|
110 |
|
|
additional information about the error in a form that is easy
|
111 |
|
|
to process with programs.
|
112 |
|
|
\fBerrorCode\fR consists of a Tcl list with one or more elements.
|
113 |
|
|
The first element of the list identifies a general class of
|
114 |
|
|
errors, and determines the format of the rest of the list.
|
115 |
|
|
The following formats for \fBerrorCode\fR are used by the
|
116 |
|
|
Tcl core; individual applications may define additional formats.
|
117 |
|
|
.RS
|
118 |
|
|
.TP
|
119 |
|
|
\fBARITH\fI code msg\fR
|
120 |
|
|
This format is used when an arithmetic error occurs (e.g. an attempt
|
121 |
|
|
to divide by zero in the \fBexpr\fR command).
|
122 |
|
|
\fICode\fR identifies the precise error and \fImsg\fR provides a
|
123 |
|
|
human-readable description of the error. \fICode\fR will be either
|
124 |
|
|
DIVZERO (for an attempt to divide by zero),
|
125 |
|
|
DOMAIN (if an argument is outside the domain of a function, such as acos(\-3)),
|
126 |
|
|
IOVERFLOW (for integer overflow),
|
127 |
|
|
OVERFLOW (for a floating-point overflow),
|
128 |
|
|
or UNKNOWN (if the cause of the error cannot be determined).
|
129 |
|
|
.TP
|
130 |
|
|
\fBCHILDKILLED\fI pid sigName msg\fR
|
131 |
|
|
This format is used when a child process has been killed because of
|
132 |
|
|
a signal. The second element of \fBerrorCode\fR will be the
|
133 |
|
|
process's identifier (in decimal).
|
134 |
|
|
The third element will be the symbolic name of the signal that caused
|
135 |
|
|
the process to terminate; it will be one of the names from the
|
136 |
|
|
include file signal.h, such as \fBSIGPIPE\fR.
|
137 |
|
|
The fourth element will be a short human-readable message
|
138 |
|
|
describing the signal, such as ``write on pipe with no readers''
|
139 |
|
|
for \fBSIGPIPE\fR.
|
140 |
|
|
.TP
|
141 |
|
|
\fBCHILDSTATUS\fI pid code\fR
|
142 |
|
|
This format is used when a child process has exited with a non-zero
|
143 |
|
|
exit status. The second element of \fBerrorCode\fR will be the
|
144 |
|
|
process's identifier (in decimal) and the third element will be the exit
|
145 |
|
|
code returned by the process (also in decimal).
|
146 |
|
|
.TP
|
147 |
|
|
\fBCHILDSUSP\fI pid sigName msg\fR
|
148 |
|
|
This format is used when a child process has been suspended because
|
149 |
|
|
of a signal.
|
150 |
|
|
The second element of \fBerrorCode\fR will be the process's identifier,
|
151 |
|
|
in decimal.
|
152 |
|
|
The third element will be the symbolic name of the signal that caused
|
153 |
|
|
the process to suspend; this will be one of the names from the
|
154 |
|
|
include file signal.h, such as \fBSIGTTIN\fR.
|
155 |
|
|
The fourth element will be a short human-readable message
|
156 |
|
|
describing the signal, such as ``background tty read''
|
157 |
|
|
for \fBSIGTTIN\fR.
|
158 |
|
|
.TP
|
159 |
|
|
\fBNONE\fR
|
160 |
|
|
This format is used for errors where no additional information is
|
161 |
|
|
available for an error besides the message returned with the
|
162 |
|
|
error. In these cases \fBerrorCode\fR will consist of a list
|
163 |
|
|
containing a single element whose contents are \fBNONE\fR.
|
164 |
|
|
.TP
|
165 |
|
|
\fBPOSIX \fIerrName msg\fR
|
166 |
|
|
If the first element of \fBerrorCode\fR is \fBPOSIX\fR, then
|
167 |
|
|
the error occurred during a POSIX kernel call.
|
168 |
|
|
The second element of the list will contain the symbolic name
|
169 |
|
|
of the error that occurred, such as \fBENOENT\fR; this will
|
170 |
|
|
be one of the values defined in the include file errno.h.
|
171 |
|
|
The third element of the list will be a human-readable
|
172 |
|
|
message corresponding to \fIerrName\fR, such as
|
173 |
|
|
``no such file or directory'' for the \fBENOENT\fR case.
|
174 |
|
|
.PP
|
175 |
|
|
To set \fBerrorCode\fR, applications should use library
|
176 |
|
|
procedures such as \fBTcl_SetErrorCode\fR and \fBTcl_PosixError\fR,
|
177 |
|
|
or they may invoke the \fBerror\fR command.
|
178 |
|
|
If one of these methods hasn't been used, then the Tcl
|
179 |
|
|
interpreter will reset the variable to \fBNONE\fR after
|
180 |
|
|
the next error.
|
181 |
|
|
.RE
|
182 |
|
|
.TP
|
183 |
|
|
\fBerrorInfo\fR
|
184 |
|
|
After an error has occurred, this string will contain one or more lines
|
185 |
|
|
identifying the Tcl commands and procedures that were being executed
|
186 |
|
|
when the most recent error occurred.
|
187 |
|
|
Its contents take the form of a stack trace showing the various
|
188 |
|
|
nested Tcl commands that had been invoked at the time of the error.
|
189 |
|
|
.TP
|
190 |
|
|
\fBtcl_library\fR
|
191 |
|
|
This variable holds the name of a directory containing the
|
192 |
|
|
system library of Tcl scripts, such as those used for auto-loading.
|
193 |
|
|
The value of this variable is returned by the \fBinfo library\fR command.
|
194 |
|
|
See the \fBlibrary\fR manual entry for details of the facilities
|
195 |
|
|
provided by the Tcl script library.
|
196 |
|
|
Normally each application or package will have its own application-specific
|
197 |
|
|
script library in addition to the Tcl script library;
|
198 |
|
|
each application should set a global variable with a name like
|
199 |
|
|
\fB$\fIapp\fB_library\fR (where \fIapp\fR is the application's name)
|
200 |
|
|
to hold the network file name for that application's library directory.
|
201 |
|
|
The initial value of \fBtcl_library\fR is set when an interpreter
|
202 |
|
|
is created by searching several different directories until one is
|
203 |
|
|
found that contains an appropriate Tcl startup script.
|
204 |
|
|
If the \fBTCL_LIBRARY\fR environment variable exists, then
|
205 |
|
|
the directory it names is checked first.
|
206 |
|
|
If \fBTCL_LIBRARY\fR isn't set or doesn't refer to an appropriate
|
207 |
|
|
directory, then Tcl checks several other directories based on a
|
208 |
|
|
compiled-in default location, the location of the binary containing
|
209 |
|
|
the application, and the current working directory.
|
210 |
|
|
.TP
|
211 |
|
|
\fBtcl_patchLevel\fR
|
212 |
|
|
When an interpreter is created Tcl initializes this variable to
|
213 |
|
|
hold a string giving the current patch level for Tcl, such as
|
214 |
|
|
\fB7.3p2\fR for Tcl 7.3 with the first two official patches, or
|
215 |
|
|
\fB7.4b4\fR for the fourth beta release of Tcl 7.4.
|
216 |
|
|
The value of this variable is returned by the \fBinfo patchlevel\fR
|
217 |
|
|
command.
|
218 |
|
|
.VS 8.0 br
|
219 |
|
|
.TP
|
220 |
|
|
\fBtcl_pkgPath\fR
|
221 |
|
|
This variable holds a list of directories indicating where packages are
|
222 |
|
|
normally installed. It typically contains either one or two entries;
|
223 |
|
|
if it contains two entries, the first is normally a directory for
|
224 |
|
|
platform-dependent packages (e.g., shared library binaries) and the
|
225 |
|
|
second is normally a directory for platform-independent packages (e.g.,
|
226 |
|
|
script files). Typically a package is installed as a subdirectory of one
|
227 |
|
|
of the entries in \fB$tcl_pkgPath\fR. The directories in
|
228 |
|
|
\fB$tcl_pkgPath\fR are included by default in the \fBauto_path\fR
|
229 |
|
|
variable, so they and their immediate subdirectories are automatically
|
230 |
|
|
searched for packages during \fBpackage require\fR commands. Note:
|
231 |
|
|
\fBtcl_pkgPath\fR it not intended to be modified by the application.
|
232 |
|
|
Its value is added to \fBauto_path\fR at startup; changes to
|
233 |
|
|
\fBtcl_pkgPath\fR are not reflected in \fBauto_path\fR. If you
|
234 |
|
|
want Tcl to search additional directories for packages you should add
|
235 |
|
|
the names of those directories to \fBauto_path\fR, not \fBtcl_pkgPath\fR.
|
236 |
|
|
.VE
|
237 |
|
|
.TP
|
238 |
|
|
\fBtcl_platform\fR
|
239 |
|
|
This is an associative array whose elements contain information about
|
240 |
|
|
the platform on which the application is running, such as the name of
|
241 |
|
|
the operating system, its current release number, and the machine's
|
242 |
|
|
instruction set. The elements listed below will always
|
243 |
|
|
be defined, but they may have empty strings as values if Tcl couldn't
|
244 |
|
|
retrieve any relevant information. In addition, extensions
|
245 |
|
|
and applications may add additional values to the array. The
|
246 |
|
|
predefined elements are:
|
247 |
|
|
.RS
|
248 |
|
|
.VS
|
249 |
|
|
.TP
|
250 |
|
|
\fBbyteOrder\fR
|
251 |
|
|
The native byte order of this machine: either \fBlittleEndian\fR or
|
252 |
|
|
\fBbigEndian\fR.
|
253 |
|
|
.VE
|
254 |
|
|
.TP
|
255 |
|
|
\fBmachine\fR
|
256 |
|
|
The instruction set executed by this machine, such as
|
257 |
|
|
\fBintel\fR, \fBPPC\fR, \fB68k\fR, or \fBsun4m\fR. On UNIX machines, this
|
258 |
|
|
is the value returned by \fBuname -m\fR.
|
259 |
|
|
.TP
|
260 |
|
|
\fBos\fR
|
261 |
|
|
The name of the operating system running on this machine,
|
262 |
|
|
such as \fBWin32s\fR, \fBWindows NT\fR, \fBMacOS\fR, or \fBSunOS\fR.
|
263 |
|
|
On UNIX machines, this is the value returned by \fBuname -s\fR.
|
264 |
|
|
.TP
|
265 |
|
|
\fBosVersion\fR
|
266 |
|
|
The version number for the operating system running on this machine.
|
267 |
|
|
On UNIX machines, this is the value returned by \fBuname -r\fR.
|
268 |
|
|
.TP
|
269 |
|
|
\fBplatform\fR
|
270 |
|
|
Either \fBwindows\fR, \fBmacintosh\fR, or \fBunix\fR. This identifies the
|
271 |
|
|
general operating environment of the machine.
|
272 |
|
|
.RE
|
273 |
|
|
.TP
|
274 |
|
|
\fBtcl_precision\fR
|
275 |
|
|
.VS
|
276 |
|
|
This variable controls the number of digits to generate
|
277 |
|
|
when converting floating-point values to strings. It defaults
|
278 |
|
|
to 12.
|
279 |
|
|
17 digits is ``perfect'' for IEEE floating-point in that it allows
|
280 |
|
|
double-precision values to be converted to strings and back to
|
281 |
|
|
binary with no loss of information. However, using 17 digits prevents
|
282 |
|
|
any rounding, which produces longer, less intuitive results. For example,
|
283 |
|
|
\fBexpr 1.4\fR returns 1.3999999999999999 with \fBtcl_precision\fR
|
284 |
|
|
set to 17, vs. 1.4 if \fBtcl_precision\fR is 12.
|
285 |
|
|
.RS
|
286 |
|
|
All interpreters in a process share a single \fBtcl_precision\fR value:
|
287 |
|
|
changing it in one interpreter will affect all other interpreters as
|
288 |
|
|
well. However, safe interpreters are not allowed to modify the
|
289 |
|
|
variable.
|
290 |
|
|
.RE
|
291 |
|
|
.VE
|
292 |
|
|
.TP
|
293 |
|
|
\fBtcl_rcFileName\fR
|
294 |
|
|
This variable is used during initialization to indicate the name of a
|
295 |
|
|
user-specific startup file. If it is set by application-specific
|
296 |
|
|
initialization, then the Tcl startup code will check for the existence
|
297 |
|
|
of this file and \fBsource\fR it if it exists. For example, for \fBwish\fR
|
298 |
|
|
the variable is set to \fB~/.wishrc\fR for Unix and \fB~/wishrc.tcl\fR
|
299 |
|
|
for Windows.
|
300 |
|
|
.TP
|
301 |
|
|
\fBtcl_rcRsrcName\fR
|
302 |
|
|
This variable is only used on Macintosh systems. The variable is used
|
303 |
|
|
during initialization to indicate the name of a user-specific
|
304 |
|
|
\fBTEXT\fR resource located in the application or extension resource
|
305 |
|
|
forks. If it is set by application-specific initialization, then the
|
306 |
|
|
Tcl startup code will check for the existence of this resource and
|
307 |
|
|
\fBsource\fR it if it exists. For example, the Macintosh \fBwish\fR
|
308 |
|
|
application has the variable is set to \fBtclshrc\fR.
|
309 |
|
|
.TP
|
310 |
|
|
\fBtcl_traceCompile\fR
|
311 |
|
|
The value of this variable can be set to control
|
312 |
|
|
how much tracing information
|
313 |
|
|
is displayed during bytecode compilation.
|
314 |
|
|
By default, tcl_traceCompile is zero and no information is displayed.
|
315 |
|
|
Setting tcl_traceCompile to 1 generates a one line summary in stdout
|
316 |
|
|
whenever a procedure or top level command is compiled.
|
317 |
|
|
Setting it to 2 generates a detailed listing in stdout of the
|
318 |
|
|
bytecode instructions emitted during every compilation.
|
319 |
|
|
This variable is useful in
|
320 |
|
|
tracking down suspected problems with the Tcl compiler.
|
321 |
|
|
It is also occasionally useful when converting
|
322 |
|
|
existing code to use Tcl8.0.
|
323 |
|
|
.TP
|
324 |
|
|
\fBtcl_traceExec\fR
|
325 |
|
|
The value of this variable can be set to control
|
326 |
|
|
how much tracing information
|
327 |
|
|
is displayed during bytecode execution.
|
328 |
|
|
By default, tcl_traceExec is zero and no information is displayed.
|
329 |
|
|
Setting tcl_traceExec to 1 generates a one line trace in stdout
|
330 |
|
|
on each call to a Tcl procedure.
|
331 |
|
|
Setting it to 2 generates a line of output
|
332 |
|
|
whenever any Tcl command is invoked
|
333 |
|
|
that contains the name of the command and its arguments.
|
334 |
|
|
Setting it to 3 produces a detailed trace showing the result of
|
335 |
|
|
executing each bytecode instruction.
|
336 |
|
|
Note that when tcl_traceExec is 2 or 3,
|
337 |
|
|
commands such as set and incr
|
338 |
|
|
that have been entirely replaced by a sequence
|
339 |
|
|
of bytecode instructions are not shown.
|
340 |
|
|
Setting this variable is useful in
|
341 |
|
|
tracking down suspected problems with the bytecode compiler
|
342 |
|
|
and interpreter.
|
343 |
|
|
It is also occasionally useful when converting
|
344 |
|
|
code to use Tcl8.0.
|
345 |
|
|
.TP
|
346 |
|
|
\fBtcl_version\fR
|
347 |
|
|
When an interpreter is created Tcl initializes this variable to
|
348 |
|
|
hold the version number for this version of Tcl in the form \fIx.y\fR.
|
349 |
|
|
Changes to \fIx\fR represent major changes with probable
|
350 |
|
|
incompatibilities and changes to \fIy\fR represent small enhancements and
|
351 |
|
|
bug fixes that retain backward compatibility.
|
352 |
|
|
The value of this variable is returned by the \fBinfo tclversion\fR
|
353 |
|
|
command.
|
354 |
|
|
|
355 |
|
|
.SH KEYWORDS
|
356 |
|
|
arithmetic, bytecode, compiler, error, environment, POSIX, precision, subprocess, variables
|