Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/tcl8.5.2/doc/tclvars.n @ 25

Last change on this file since 25 was 25, checked in by landauf, 16 years ago

added tcl to libs

File size: 16.7 KB
Line 
1'\"
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.35 2007/12/13 15:22:33 dgp 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
15tclvars \- Variables used by Tcl
16.BE
17.SH DESCRIPTION
18.PP
19The following global variables are created and managed automatically
20by the Tcl library.  Except where noted below, these variables should
21normally be treated as read-only by application-specific code and by users.
22.TP
23\fBenv\fR
24This variable is maintained by Tcl as an array
25whose elements are the environment variables for the process.
26Reading an element will return the value of the corresponding
27environment variable.
28Setting an element of the array will modify the corresponding
29environment variable or create a new one if it does not already
30exist.
31Unsetting an element of \fBenv\fR will remove the corresponding
32environment variable.
33Changes to the \fBenv\fR array will affect the environment
34passed to children by commands like \fBexec\fR.
35If the entire \fBenv\fR array is unset then Tcl will stop
36monitoring \fBenv\fR accesses and will not update environment
37variables.
38.RS
39.PP
40Under Windows, the environment variables PATH and COMSPEC in any
41capitalization are converted automatically to upper case.  For instance, the
42PATH variable could be exported by the operating system as
43.QW path ,
44.QW Path ,
45.QW PaTh ,
46etc., causing otherwise simple Tcl code to have to
47support many special cases.  All other environment variables inherited by
48Tcl are left unmodified.  Setting an env array variable to blank is the
49same as unsetting it as this is the behavior of the underlying Windows OS.
50It should be noted that relying on an existing and empty environment variable
51will not work on Windows and is discouraged for cross-platform usage.
52.RE
53.TP
54\fBerrorCode\fR
55This variable holds the value of the \fB\-errorcode\fR return option
56set by the most recent error that occurred in this interpreter.
57This list value represents additional information about the error
58in a form that is easy to process with programs.
59The first element of the list identifies a general class of
60errors, and determines the format of the rest of the list.
61The following formats for \fB\-errorcode\fR return options
62are used by the Tcl core; individual applications may define
63additional formats.
64.RS
65.TP
66\fBARITH\fI code msg\fR
67.
68This format is used when an arithmetic error occurs (e.g. an attempt
69to divide zero by zero in the \fBexpr\fR command).
70\fICode\fR identifies the precise error and \fImsg\fR provides a
71human-readable description of the error.  \fICode\fR will be either
72DIVZERO (for an attempt to divide by zero),
73DOMAIN (if an argument is outside the domain of a function, such as acos(\-3)),
74IOVERFLOW (for integer overflow),
75OVERFLOW (for a floating-point overflow),
76or UNKNOWN (if the cause of the error cannot be determined).
77.RS
78.PP
79Detection of these errors depends in part on the underlying hardware
80and system libraries.
81.RE
82.TP
83\fBCHILDKILLED\fI pid sigName msg\fR
84This format is used when a child process has been killed because of
85a signal.  The \fIpid\fR element will be the process's identifier (in decimal).
86The \fIsigName\fR element will be the symbolic name of the signal that caused
87the process to terminate; it will be one of the names from the
88include file signal.h, such as \fBSIGPIPE\fR.
89The \fImsg\fR element will be a short human-readable message
90describing the signal, such as
91.QW "write on pipe with no readers"
92for \fBSIGPIPE\fR.
93.TP
94\fBCHILDSTATUS\fI pid code\fR
95This format is used when a child process has exited with a non-zero
96exit status.  The \fIpid\fR element will be the
97process's identifier (in decimal) and the \fIcode\fR element will be the exit
98code returned by the process (also in decimal).
99.TP
100\fBCHILDSUSP\fI pid sigName msg\fR
101This format is used when a child process has been suspended because
102of a signal.
103The \fIpid\fR element will be the process's identifier, in decimal.
104The \fIsigName\fR element will be the symbolic name of the signal that caused
105the process to suspend; this will be one of the names from the
106include file signal.h, such as \fBSIGTTIN\fR.
107The \fImsg\fR element will be a short human-readable message
108describing the signal, such as
109.QW "background tty read"
110for \fBSIGTTIN\fR.
111.TP
112\fBNONE\fR
113This format is used for errors where no additional information is
114available for an error besides the message returned with the
115error.  In these cases the \fB\-errorcode\fR return option
116will consist of a list containing a single element whose
117contents are \fBNONE\fR.
118.TP
119\fBPOSIX \fIerrName msg\fR
120If the first element is \fBPOSIX\fR, then
121the error occurred during a POSIX kernel call.
122The \fIerrName\fR element will contain the symbolic name
123of the error that occurred, such as \fBENOENT\fR; this will
124be one of the values defined in the include file errno.h.
125The \fImsg\fR element will be a human-readable
126message corresponding to \fIerrName\fR, such as
127.QW "no such file or directory"
128for the \fBENOENT\fR case.
129.PP
130To set the \fB\-errorcode\fR return option, applications should use library
131procedures such as \fBTcl_SetObjErrorCode\fR, \fBTcl_SetReturnOptions\fR,
132and \fBTcl_PosixError\fR, or they may invoke the \fB\-errorcode\fR
133option of the \fBreturn\fR command.
134If none of these methods for setting the error code has been used,
135the Tcl interpreter will reset the variable to \fBNONE\fR after
136the next error.
137.RE
138.\" .TP
139.\" \fBTCL\fR ...
140.\" .
141.\" Indicates some sort of problem generated in relation to Tcl itself,
142.\" e.g. a failure to look up a channel or variable.
143.TP
144\fBerrorInfo\fR
145This variable holds the value of the \fB\-errorinfo\fR return option
146set by the most recent error that occurred in this interpreter.
147This string value will contain one or more lines
148identifying the Tcl commands and procedures that were being executed
149when the most recent error occurred.
150Its contents take the form of a stack trace showing the various
151nested Tcl commands that had been invoked at the time of the error.
152.TP
153\fBtcl_library\fR
154This variable holds the name of a directory containing the
155system library of Tcl scripts, such as those used for auto-loading.
156The value of this variable is returned by the \fBinfo library\fR command.
157See the \fBlibrary\fR manual entry for details of the facilities
158provided by the Tcl script library.
159Normally each application or package will have its own application-specific
160script library in addition to the Tcl script library;
161each application should set a global variable with a name like
162\fB$\fIapp\fB_library\fR (where \fIapp\fR is the application's name)
163to hold the network file name for that application's library directory.
164The initial value of \fBtcl_library\fR is set when an interpreter
165is created by searching several different directories until one is
166found that contains an appropriate Tcl startup script.
167If the \fBTCL_LIBRARY\fR environment variable exists, then
168the directory it names is checked first.
169If \fBTCL_LIBRARY\fR is not set or doesn't refer to an appropriate
170directory, then Tcl checks several other directories based on a
171compiled-in default location, the location of the binary containing
172the application, and the current working directory.
173.TP
174\fBtcl_patchLevel\fR
175.
176When an interpreter is created Tcl initializes this variable to
177hold a string giving the current patch level for Tcl, such as
178\fB8.4.16\fR for Tcl 8.4 with the first sixteen official patches, or
179\fB8.5b3\fR for the third beta release of Tcl 8.5.
180The value of this variable is returned by the \fBinfo patchlevel\fR
181command.
182.TP
183\fBtcl_pkgPath\fR
184This variable holds a list of directories indicating where packages are
185normally installed.  It is not used on Windows.  It typically contains
186either one or two entries; if it contains two entries, the first is
187normally a directory for platform-dependent packages (e.g., shared library
188binaries) and the second is normally a directory for platform-independent
189packages (e.g., script files). Typically a package is installed as a
190subdirectory of one of the entries in \fB$tcl_pkgPath\fR. The directories
191in \fB$tcl_pkgPath\fR are included by default in the \fBauto_path\fR
192variable, so they and their immediate subdirectories are automatically
193searched for packages during \fBpackage require\fR commands.  Note:
194\fBtcl_pkgPath\fR is not intended to be modified by the application.  Its
195value is added to \fBauto_path\fR at startup; changes to \fBtcl_pkgPath\fR
196are not reflected in \fBauto_path\fR.  If you want Tcl to search additional
197directories for packages you should add the names of those directories to
198\fBauto_path\fR, not \fBtcl_pkgPath\fR.
199.TP
200\fBtcl_platform\fR
201This is an associative array whose elements contain information about
202the platform on which the application is running, such as the name of
203the operating system, its current release number, and the machine's
204instruction set.  The elements listed below will always
205be defined, but they may have empty strings as values if Tcl could not
206retrieve any relevant information.  In addition, extensions
207and applications may add additional values to the array.  The
208predefined elements are:
209.RS
210.TP
211\fBbyteOrder\fR
212The native byte order of this machine: either \fBlittleEndian\fR or
213\fBbigEndian\fR.
214.TP
215\fBdebug\fR
216If this variable exists, then the interpreter was compiled with and linked
217to a debug-enabled C run-time.  This variable will only exist on Windows,
218so extension writers can specify which package to load depending on the
219C run-time library that is in use.  This is not an indication that this core
220contains symbols.
221.TP
222\fBmachine\fR
223The instruction set executed by this machine, such as
224\fBintel\fR, \fBPPC\fR, \fB68k\fR, or \fBsun4m\fR.  On UNIX machines, this
225is the value returned by \fBuname -m\fR.
226.TP
227\fBos\fR
228The name of the operating system running on this machine,
229such as \fBWindows 95\fR, \fBWindows NT\fR, or \fBSunOS\fR.
230On UNIX machines, this is the value returned by \fBuname -s\fR.
231On Windows 95 and Windows 98, the value returned will be \fBWindows
23295\fR to provide better backwards compatibility to Windows 95; to
233distinguish between the two, check the \fBosVersion\fR.
234.TP
235\fBosVersion\fR
236The version number for the operating system running on this machine.
237On UNIX machines, this is the value returned by \fBuname -r\fR.  On
238Windows 95, the version will be 4.0; on Windows 98, the version will
239be 4.10.
240.TP
241\fBplatform\fR
242Either \fBwindows\fR, or \fBunix\fR.  This identifies the
243general operating environment of the machine.
244.TP
245\fBthreaded\fR
246If this variable exists, then the interpreter
247was compiled with threads enabled.
248.TP
249\fBuser\fR
250This identifies the
251current user based on the login information available on the platform.
252This comes from the USER or LOGNAME environment variable on Unix,
253and the value from GetUserName on Windows.
254.TP
255\fBwordSize\fR
256This gives the size of the native-machine word in bytes (strictly, it
257is same as the result of evaluating \fIsizeof(long)\fR in C.)
258.TP
259\fBpointerSize\fR
260This gives the size of the native-machine pointer in bytes (strictly, it
261is same as the result of evaluating \fIsizeof(void*)\fR in C.)
262.RE
263.TP
264\fBtcl_precision\fR
265This variable controls the number of digits to generate
266when converting floating-point values to strings.  It defaults
267.VS 8.5
268to 0.  \fIApplications should not change this value;\fR it is
269provided for compatibility with legacy code.
270.PP
271.RS
272The default value of 0 is special, meaning that Tcl should
273convert numbers using as few digits as possible while still
274distinguishing any floating point number from its nearest
275neighbours.  It differs from using an arbitrarily high value
276for \fItcl_precision\fR in that an inexact number like \fI1.4\fR
277will convert as \fI1.4\fR rather than \fI1.3999999999999999\fR
278even though the latter is nearer to the exact value of the
279binary number.
280.RE
281.VE 8.5
282.PP
283.RS
28417 digits is
285.QW perfect
286for IEEE floating-point in that it allows
287double-precision values to be converted to strings and back to
288binary with no loss of information.  However, using 17 digits prevents
289any rounding, which produces longer, less intuitive results.  For example,
290\fBexpr {1.4}\fR returns 1.3999999999999999 with \fBtcl_precision\fR
291set to 17, vs. 1.4 if \fBtcl_precision\fR is 12.
292.RE
293.PP
294.RS
295All interpreters in a thread share a single \fBtcl_precision\fR value:
296changing it in one interpreter will affect all other interpreters as
297well.  However, safe interpreters are not allowed to modify the
298variable.
299.RE
300.TP
301\fBtcl_rcFileName\fR
302This variable is used during initialization to indicate the name of a
303user-specific startup file.  If it is set by application-specific
304initialization, then the Tcl startup code will check for the existence
305of this file and \fBsource\fR it if it exists.  For example, for \fBwish\fR
306the variable is set to \fB~/.wishrc\fR for Unix and \fB~/wishrc.tcl\fR
307for Windows.
308.TP
309\fBtcl_traceCompile\fR
310The value of this variable can be set to control
311how much tracing information
312is displayed during bytecode compilation.
313By default, tcl_traceCompile is zero and no information is displayed.
314Setting tcl_traceCompile to 1 generates a one-line summary in stdout
315whenever a procedure or top-level command is compiled.
316Setting it to 2 generates a detailed listing in stdout of the
317bytecode instructions emitted during every compilation.
318This variable is useful in
319tracking down suspected problems with the Tcl compiler.
320.PP
321.RS
322This variable and functionality only exist if
323\fBTCL_COMPILE_DEBUG\fR was defined during Tcl's compilation.
324.RE
325.TP
326\fBtcl_traceExec\fR
327The value of this variable can be set to control
328how much tracing information
329is displayed during bytecode execution.
330By default, tcl_traceExec is zero and no information is displayed.
331Setting tcl_traceExec to 1 generates a one-line trace in stdout
332on each call to a Tcl procedure.
333Setting it to 2 generates a line of output
334whenever any Tcl command is invoked
335that contains the name of the command and its arguments.
336Setting it to 3 produces a detailed trace showing the result of
337executing each bytecode instruction.
338Note that when tcl_traceExec is 2 or 3,
339commands such as \fBset\fR and \fBincr\fR
340that have been entirely replaced by a sequence
341of bytecode instructions are not shown.
342Setting this variable is useful in
343tracking down suspected problems with the bytecode compiler
344and interpreter.
345.PP
346.RS
347This variable and functionality only exist if
348\fBTCL_COMPILE_DEBUG\fR was defined during Tcl's compilation.
349.RE
350.TP
351\fBtcl_wordchars\fR
352The value of this variable is a regular expression that can be set to
353control what are considered
354.QW word
355characters, for instances like
356selecting a word by double-clicking in text in Tk.  It is platform
357dependent.  On Windows, it defaults to \fB\eS\fR, meaning anything
358but a Unicode space character.  Otherwise it defaults to \fB\ew\fR,
359which is any Unicode word character (number, letter, or underscore).
360.TP
361\fBtcl_nonwordchars\fR
362The value of this variable is a regular expression that can be set to
363control what are considered
364.QW non-word
365characters, for instances like
366selecting a word by double-clicking in text in Tk.  It is platform
367dependent.  On Windows, it defaults to \fB\es\fR, meaning any Unicode space
368character.  Otherwise it defaults to \fB\eW\fR, which is anything but a
369Unicode word character (number, letter, or underscore).
370.TP
371\fBtcl_version\fR
372When an interpreter is created Tcl initializes this variable to
373hold the version number for this version of Tcl in the form \fIx.y\fR.
374Changes to \fIx\fR represent major changes with probable
375incompatibilities and changes to \fIy\fR represent small enhancements and
376bug fixes that retain backward compatibility.
377The value of this variable is returned by the \fBinfo tclversion\fR
378command.
379.SH "OTHER GLOBAL VARIABLES"
380The following variables are only guaranteed to exist in \fBtclsh\fR
381and \fBwish\fR executables; the Tcl library does not define them
382itself but many Tcl environments do.
383.TP 6
384\fBargc\fR
385The number of arguments to \fBtclsh\fR or \fBwish\fR.
386.TP 6
387\fBargv\fR
388Tcl list of arguments to \fBtclsh\fR or \fBwish\fR.
389.TP 6
390\fBargv0\fR
391The script that \fBtclsh\fR or \fBwish\fR started executing (if it was
392specified) or otherwise the name by which \fBtclsh\fR or \fBwish\fR
393was invoked.
394.TP 6
395\fBtcl_interactive\fR
396Contains 1 if \fBtclsh\fR or \fBwish\fR is running interactively (no
397script was specified and standard input is a terminal-like device), 0
398otherwise.
399.PP
400The \fBwish\fR executable additionally specifies the following global
401variable:
402.TP 6
403\fBgeometry\fR
404If set, contains the user-supplied geometry specification to use for
405the main Tk window.
406.SH "SEE ALSO"
407eval(n), tclsh(1), wish(1)
408.SH KEYWORDS
409arithmetic, bytecode, compiler, error, environment, POSIX, precision, subprocess, variables
Note: See TracBrowser for help on using the repository browser.