update NEWS
[manpages-zh.git] / raw / mann / tclvars.n
blobe660e2b4949e6a4dbfbf731685c9e3924bbd3361
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.1 2003/12/20 03:31:54 bbbush Exp $
9 '\"
10 '\" The definitions below are for supplemental macros used in Tcl/Tk
11 '\" manual entries.
12 '\"
13 '\" .AP type name in/out ?indent?
14 '\" Start paragraph describing an argument to a library procedure.
15 '\" type is type of argument (int, etc.), in/out is either "in", "out",
16 '\" or "in/out" to describe whether procedure reads or modifies arg,
17 '\" and indent is equivalent to second arg of .IP (shouldn't ever be
18 '\" needed; use .AS below instead)
19 '\"
20 '\" .AS ?type? ?name?
21 '\" Give maximum sizes of arguments for setting tab stops. Type and
22 '\" name are examples of largest possible arguments that will be passed
23 '\" to .AP later. If args are omitted, default tab stops are used.
24 '\"
25 '\" .BS
26 '\" Start box enclosure. From here until next .BE, everything will be
27 '\" enclosed in one large box.
28 '\"
29 '\" .BE
30 '\" End of box enclosure.
31 '\"
32 '\" .CS
33 '\" Begin code excerpt.
34 '\"
35 '\" .CE
36 '\" End code excerpt.
37 '\"
38 '\" .VS ?version? ?br?
39 '\" Begin vertical sidebar, for use in marking newly-changed parts
40 '\" of man pages. The first argument is ignored and used for recording
41 '\" the version when the .VS was added, so that the sidebars can be
42 '\" found and removed when they reach a certain age. If another argument
43 '\" is present, then a line break is forced before starting the sidebar.
44 '\"
45 '\" .VE
46 '\" End of vertical sidebar.
47 '\"
48 '\" .DS
49 '\" Begin an indented unfilled display.
50 '\"
51 '\" .DE
52 '\" End of indented unfilled display.
53 '\"
54 '\" .SO
55 '\" Start of list of standard options for a Tk widget. The
56 '\" options follow on successive lines, in four columns separated
57 '\" by tabs.
58 '\"
59 '\" .SE
60 '\" End of list of standard options for a Tk widget.
61 '\"
62 '\" .OP cmdName dbName dbClass
63 '\" Start of description of a specific option. cmdName gives the
64 '\" option's name as specified in the class command, dbName gives
65 '\" the option's name in the option database, and dbClass gives
66 '\" the option's class in the option database.
67 '\"
68 '\" .UL arg1 arg2
69 '\" Print arg1 underlined, then print arg2 normally.
70 '\"
71 '\" RCS: @(#) $Id: tclvars.n,v 1.1 2003/12/20 03:31:54 bbbush Exp $
72 '\"
73 '\" # Set up traps and other miscellaneous stuff for Tcl/Tk man pages.
74 .if t .wh -1.3i ^B
75 .nr ^l \n(.l
76 .ad b
77 '\" # Start an argument description
78 .de AP
79 .ie !"\\$4"" .TP \\$4
80 .el \{\
81 . ie !"\\$2"" .TP \\n()Cu
82 . el .TP 15
83 .\}
84 .ta \\n()Au \\n()Bu
85 .ie !"\\$3"" \{\
86 \&\\$1 \\fI\\$2\\fP (\\$3)
87 .\".b
88 .\}
89 .el \{\
90 .br
91 .ie !"\\$2"" \{\
92 \&\\$1 \\fI\\$2\\fP
93 .\}
94 .el \{\
95 \&\\fI\\$1\\fP
96 .\}
97 .\}
99 '\" # define tabbing values for .AP
100 .de AS
101 .nr )A 10n
102 .if !"\\$1"" .nr )A \\w'\\$1'u+3n
103 .nr )B \\n()Au+15n
105 .if !"\\$2"" .nr )B \\w'\\$2'u+\\n()Au+3n
106 .nr )C \\n()Bu+\\w'(in/out)'u+2n
108 .AS Tcl_Interp Tcl_CreateInterp in/out
109 '\" # BS - start boxed text
110 '\" # ^y = starting y location
111 '\" # ^b = 1
112 .de BS
114 .mk ^y
115 .nr ^b 1u
116 .if n .nf
117 .if n .ti 0
118 .if n \l'\\n(.lu\(ul'
119 .if n .fi
121 '\" # BE - end boxed text (draw box now)
122 .de BE
124 .ti 0
125 .mk ^t
126 .ie n \l'\\n(^lu\(ul'
127 .el \{\
128 .\" Draw four-sided box normally, but don't draw top of
129 .\" box if the box started on an earlier page.
130 .ie !\\n(^b-1 \{\
131 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
133 .el \}\
134 \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\l'|0u-1.5n\(ul'
139 .nr ^b 0
141 '\" # VS - start vertical sidebar
142 '\" # ^Y = starting y location
143 '\" # ^v = 1 (for troff; for nroff this doesn't matter)
144 .de VS
145 .if !"\\$2"" .br
146 .mk ^Y
147 .ie n 'mc \s12\(br\s0
148 .el .nr ^v 1u
150 '\" # VE - end of vertical sidebar
151 .de VE
152 .ie n 'mc
153 .el \{\
154 .ev 2
156 .ti 0
157 .mk ^t
158 \h'|\\n(^lu+3n'\L'|\\n(^Yu-1v\(bv'\v'\\n(^tu+1v-\\n(^Yu'\h'-|\\n(^lu+3n'
159 .sp -1
163 .nr ^v 0
165 '\" # Special macro to handle page bottom: finish off current
166 '\" # box/sidebar if in box/sidebar mode, then invoked standard
167 '\" # page bottom macro.
168 .de ^B
169 .ev 2
170 'ti 0
172 .mk ^t
173 .if \\n(^b \{\
174 .\" Draw three-sided box if this is the box's first page,
175 .\" draw two sides but no top otherwise.
176 .ie !\\n(^b-1 \h'-1.5n'\L'|\\n(^yu-1v'\l'\\n(^lu+3n\(ul'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
177 .el \h'-1.5n'\L'|\\n(^yu-1v'\h'\\n(^lu+3n'\L'\\n(^tu+1v-\\n(^yu'\h'|0u'\c
179 .if \\n(^v \{\
180 .nr ^x \\n(^tu+1v-\\n(^Yu
181 \kx\h'-\\nxu'\h'|\\n(^lu+3n'\ky\L'-\\n(^xu'\v'\\n(^xu'\h'|0u'\c
186 .if \\n(^b \{\
187 .mk ^y
188 .nr ^b 2
190 .if \\n(^v \{\
191 .mk ^Y
194 '\" # DS - begin display
195 .de DS
200 '\" # DE - end display
201 .de DE
206 '\" # SO - start of list of standard options
207 .de SO
208 .SH "STANDARD OPTIONS"
211 .ta 5.5c 11c
212 .ft B
214 '\" # SE - end of list of standard options
215 .de SE
217 .ft R
219 See the \\fBoptions\\fR manual entry for details on the standard options.
221 '\" # OP - start of full description for a single option
222 .de OP
225 .ta 4c
226 Command-Line Name: \\fB\\$1\\fR
227 Database Name: \\fB\\$2\\fR
228 Database Class: \\fB\\$3\\fR
232 '\" # CS - begin code excerpt
233 .de CS
236 .ta .25i .5i .75i 1i
238 '\" # CE - end code excerpt
239 .de CE
243 .de UL
244 \\$1\l'|0\(ul'\\$2
246 .TH tclvars n 8.0 Tcl "Tcl Built-In Commands"
248 '\" Note: do not modify the .SH NAME line immediately below!
249 .SH NAME
250 tclvars \- Variables used by Tcl
253 .SH DESCRIPTION
255 The following global variables are created and managed automatically
256 by the Tcl library. Except where noted below, these variables should
257 normally be treated as read-only by application-specific code and by users.
259 \fBenv\fR
260 This variable is maintained by Tcl as an array
261 whose elements are the environment variables for the process.
262 Reading an element will return the value of the corresponding
263 environment variable.
264 Setting an element of the array will modify the corresponding
265 environment variable or create a new one if it doesn't already
266 exist.
267 Unsetting an element of \fBenv\fR will remove the corresponding
268 environment variable.
269 Changes to the \fBenv\fR array will affect the environment
270 passed to children by commands like \fBexec\fR.
271 If the entire \fBenv\fR array is unset then Tcl will stop
272 monitoring \fBenv\fR accesses and will not update environment
273 variables.
275 .VS 8.0
276 Under Windows, the environment variables PATH and COMSPEC in any
277 capitalization are converted automatically to upper case. For instance, the
278 PATH variable could be exported by the operating system as ``path'',
279 ``Path'', ``PaTh'', etc., causing otherwise simple Tcl code to have to
280 support many special cases. All other environment variables inherited by
281 Tcl are left unmodified.
285 On the Macintosh, the environment variable is constructed by Tcl as no
286 global environment variable exists. The environment variables that
287 are created for Tcl include:
289 \fBLOGIN\fR
290 This holds the Chooser name of the Macintosh.
292 \fBUSER\fR
293 This also holds the Chooser name of the Macintosh.
295 \fBSYS_FOLDER\fR
296 The path to the system directory.
298 \fBAPPLE_M_FOLDER\fR
299 The path to the Apple Menu directory.
301 \fBCP_FOLDER\fR
302 The path to the control panels directory.
304 \fBDESK_FOLDER\fR
305 The path to the desk top directory.
307 \fBEXT_FOLDER\fR
308 The path to the system extensions directory.
310 \fBPREF_FOLDER\fR
311 The path to the preferences directory.
313 \fBPRINT_MON_FOLDER\fR
314 The path to the print monitor directory.
316 \fBSHARED_TRASH_FOLDER\fR
317 The path to the network trash directory.
319 \fBTRASH_FOLDER\fR
320 The path to the trash directory.
322 \fBSTART_UP_FOLDER\fR
323 The path to the start up directory.
325 \fBHOME\fR
326 The path to the application's default directory.
328 You can also create your own environment variables for the Macintosh.
329 A file named \fITcl Environment Variables\fR may be placed in the
330 preferences folder in the Mac system folder. Each line of this file
331 should be of the form \fIVAR_NAME=var_data\fR.
333 The last alternative is to place environment variables in a 'STR#'
334 resource named \fITcl Environment Variables\fR of the application. This
335 is considered a little more ``Mac like'' than a Unix style Environment
336 Variable file. Each entry in the 'STR#' resource has the same format
337 as above. The source code file \fItclMacEnv.c\fR contains the
338 implementation of the env mechanisms. This file contains many
339 #define's that allow customization of the env mechanisms to fit your
340 applications needs.
343 \fBerrorCode\fR
344 After an error has occurred, this variable will be set to hold
345 additional information about the error in a form that is easy
346 to process with programs.
347 \fBerrorCode\fR consists of a Tcl list with one or more elements.
348 The first element of the list identifies a general class of
349 errors, and determines the format of the rest of the list.
350 The following formats for \fBerrorCode\fR are used by the
351 Tcl core; individual applications may define additional formats.
354 \fBARITH\fI code msg\fR
355 This format is used when an arithmetic error occurs (e.g. an attempt
356 to divide by zero in the \fBexpr\fR command).
357 \fICode\fR identifies the precise error and \fImsg\fR provides a
358 human-readable description of the error. \fICode\fR will be either
359 DIVZERO (for an attempt to divide by zero),
360 DOMAIN (if an argument is outside the domain of a function, such as acos(\-3)),
361 IOVERFLOW (for integer overflow),
362 OVERFLOW (for a floating-point overflow),
363 or UNKNOWN (if the cause of the error cannot be determined).
365 \fBCHILDKILLED\fI pid sigName msg\fR
366 This format is used when a child process has been killed because of
367 a signal. The second element of \fBerrorCode\fR will be the
368 process's identifier (in decimal).
369 The third element will be the symbolic name of the signal that caused
370 the process to terminate; it will be one of the names from the
371 include file signal.h, such as \fBSIGPIPE\fR.
372 The fourth element will be a short human-readable message
373 describing the signal, such as ``write on pipe with no readers''
374 for \fBSIGPIPE\fR.
376 \fBCHILDSTATUS\fI pid code\fR
377 This format is used when a child process has exited with a non-zero
378 exit status. The second element of \fBerrorCode\fR will be the
379 process's identifier (in decimal) and the third element will be the exit
380 code returned by the process (also in decimal).
382 \fBCHILDSUSP\fI pid sigName msg\fR
383 This format is used when a child process has been suspended because
384 of a signal.
385 The second element of \fBerrorCode\fR will be the process's identifier,
386 in decimal.
387 The third element will be the symbolic name of the signal that caused
388 the process to suspend; this will be one of the names from the
389 include file signal.h, such as \fBSIGTTIN\fR.
390 The fourth element will be a short human-readable message
391 describing the signal, such as ``background tty read''
392 for \fBSIGTTIN\fR.
394 \fBNONE\fR
395 This format is used for errors where no additional information is
396 available for an error besides the message returned with the
397 error. In these cases \fBerrorCode\fR will consist of a list
398 containing a single element whose contents are \fBNONE\fR.
400 \fBPOSIX \fIerrName msg\fR
401 If the first element of \fBerrorCode\fR is \fBPOSIX\fR, then
402 the error occurred during a POSIX kernel call.
403 The second element of the list will contain the symbolic name
404 of the error that occurred, such as \fBENOENT\fR; this will
405 be one of the values defined in the include file errno.h.
406 The third element of the list will be a human-readable
407 message corresponding to \fIerrName\fR, such as
408 ``no such file or directory'' for the \fBENOENT\fR case.
410 To set \fBerrorCode\fR, applications should use library
411 procedures such as \fBTcl_SetErrorCode\fR and \fBTcl_PosixError\fR,
412 or they may invoke the \fBerror\fR command.
413 If one of these methods hasn't been used, then the Tcl
414 interpreter will reset the variable to \fBNONE\fR after
415 the next error.
418 \fBerrorInfo\fR
419 After an error has occurred, this string will contain one or more lines
420 identifying the Tcl commands and procedures that were being executed
421 when the most recent error occurred.
422 Its contents take the form of a stack trace showing the various
423 nested Tcl commands that had been invoked at the time of the error.
425 \fBtcl_library\fR
426 This variable holds the name of a directory containing the
427 system library of Tcl scripts, such as those used for auto-loading.
428 The value of this variable is returned by the \fBinfo library\fR command.
429 See the \fBlibrary\fR manual entry for details of the facilities
430 provided by the Tcl script library.
431 Normally each application or package will have its own application-specific
432 script library in addition to the Tcl script library;
433 each application should set a global variable with a name like
434 \fB$\fIapp\fB_library\fR (where \fIapp\fR is the application's name)
435 to hold the network file name for that application's library directory.
436 The initial value of \fBtcl_library\fR is set when an interpreter
437 is created by searching several different directories until one is
438 found that contains an appropriate Tcl startup script.
439 If the \fBTCL_LIBRARY\fR environment variable exists, then
440 the directory it names is checked first.
441 If \fBTCL_LIBRARY\fR isn't set or doesn't refer to an appropriate
442 directory, then Tcl checks several other directories based on a
443 compiled-in default location, the location of the binary containing
444 the application, and the current working directory.
446 \fBtcl_patchLevel\fR
447 When an interpreter is created Tcl initializes this variable to
448 hold a string giving the current patch level for Tcl, such as
449 \fB7.3p2\fR for Tcl 7.3 with the first two official patches, or
450 \fB7.4b4\fR for the fourth beta release of Tcl 7.4.
451 The value of this variable is returned by the \fBinfo patchlevel\fR
452 command.
453 .VS 8.0 br
455 \fBtcl_pkgPath\fR
456 This variable holds a list of directories indicating where packages are
457 normally installed. It is not used on Windows. It typically contains
458 either one or two entries; if it contains two entries, the first is
459 normally a directory for platform-dependent packages (e.g., shared library
460 binaries) and the second is normally a directory for platform-independent
461 packages (e.g., script files). Typically a package is installed as a
462 subdirectory of one of the entries in \fB$tcl_pkgPath\fR. The directories
463 in \fB$tcl_pkgPath\fR are included by default in the \fBauto_path\fR
464 variable, so they and their immediate subdirectories are automatically
465 searched for packages during \fBpackage require\fR commands. Note:
466 \fBtcl_pkgPath\fR it not intended to be modified by the application. Its
467 value is added to \fBauto_path\fR at startup; changes to \fBtcl_pkgPath\fR
468 are not reflected in \fBauto_path\fR. If you want Tcl to search additional
469 directories for packages you should add the names of those directories to
470 \fBauto_path\fR, not \fBtcl_pkgPath\fR.
473 \fBtcl_platform\fR
474 This is an associative array whose elements contain information about
475 the platform on which the application is running, such as the name of
476 the operating system, its current release number, and the machine's
477 instruction set. The elements listed below will always
478 be defined, but they may have empty strings as values if Tcl couldn't
479 retrieve any relevant information. In addition, extensions
480 and applications may add additional values to the array. The
481 predefined elements are:
490 \fBbyteOrder\fR
491 The native byte order of this machine: either \fBlittleEndian\fR or
492 \fBbigEndian\fR.
495 \fBdebug\fR
496 If this variable exists, then the interpreter
497 was compiled with debugging symbols enabled. This varible will only
498 exist on Windows so extension writers can specify which package to load
499 depending on the C run-time library that is loaded.
501 \fBmachine\fR
502 The instruction set executed by this machine, such as
503 \fBintel\fR, \fBPPC\fR, \fB68k\fR, or \fBsun4m\fR. On UNIX machines, this
504 is the value returned by \fBuname -m\fR.
506 \fBos\fR
507 The name of the operating system running on this machine,
508 such as \fBWindows 95\fR, \fBWindows NT\fR, \fBMacOS\fR, or \fBSunOS\fR.
509 On UNIX machines, this is the value returned by \fBuname -s\fR.
510 On Windows 95 and Windows 98, the value returned will be \fBWindows
511 95\fR to provide better backwards compatibility to Windows 95; to
512 distinguish between the two, check the \fBosVersion\fR.
514 \fBosVersion\fR
515 The version number for the operating system running on this machine.
516 On UNIX machines, this is the value returned by \fBuname -r\fR. On
517 Windows 95, the version will be 4.0; on Windows 98, the version will
518 be 4.10.
520 \fBplatform\fR
521 Either \fBwindows\fR, \fBmacintosh\fR, or \fBunix\fR. This identifies the
522 general operating environment of the machine.
524 \fBthreaded\fR
525 If this variable exists, then the interpreter
526 was compiled with threads enabled.
528 \fBuser\fR
529 This identifies the
530 current user based on the login information available on the platform.
531 This comes from the USER or LOGNAME environment variable on Unix,
532 and the value from GetUserName on Windows and Macintosh.
535 \fBtcl_precision\fR
537 This variable controls the number of digits to generate
538 when converting floating-point values to strings. It defaults
539 to 12.
540 17 digits is ``perfect'' for IEEE floating-point in that it allows
541 double-precision values to be converted to strings and back to
542 binary with no loss of information. However, using 17 digits prevents
543 any rounding, which produces longer, less intuitive results. For example,
544 \fBexpr 1.4\fR returns 1.3999999999999999 with \fBtcl_precision\fR
545 set to 17, vs. 1.4 if \fBtcl_precision\fR is 12.
547 All interpreters in a process share a single \fBtcl_precision\fR value:
548 changing it in one interpreter will affect all other interpreters as
549 well. However, safe interpreters are not allowed to modify the
550 variable.
554 \fBtcl_rcFileName\fR
555 This variable is used during initialization to indicate the name of a
556 user-specific startup file. If it is set by application-specific
557 initialization, then the Tcl startup code will check for the existence
558 of this file and \fBsource\fR it if it exists. For example, for \fBwish\fR
559 the variable is set to \fB~/.wishrc\fR for Unix and \fB~/wishrc.tcl\fR
560 for Windows.
562 \fBtcl_rcRsrcName\fR
563 This variable is only used on Macintosh systems. The variable is used
564 during initialization to indicate the name of a user-specific
565 \fBTEXT\fR resource located in the application or extension resource
566 forks. If it is set by application-specific initialization, then the
567 Tcl startup code will check for the existence of this resource and
568 \fBsource\fR it if it exists. For example, the Macintosh \fBwish\fR
569 application has the variable is set to \fBtclshrc\fR.
571 \fBtcl_traceCompile\fR
572 The value of this variable can be set to control
573 how much tracing information
574 is displayed during bytecode compilation.
575 By default, tcl_traceCompile is zero and no information is displayed.
576 Setting tcl_traceCompile to 1 generates a one line summary in stdout
577 whenever a procedure or top level command is compiled.
578 Setting it to 2 generates a detailed listing in stdout of the
579 bytecode instructions emitted during every compilation.
580 This variable is useful in
581 tracking down suspected problems with the Tcl compiler.
582 It is also occasionally useful when converting
583 existing code to use Tcl8.0.
585 \fBtcl_traceExec\fR
586 The value of this variable can be set to control
587 how much tracing information
588 is displayed during bytecode execution.
589 By default, tcl_traceExec is zero and no information is displayed.
590 Setting tcl_traceExec to 1 generates a one line trace in stdout
591 on each call to a Tcl procedure.
592 Setting it to 2 generates a line of output
593 whenever any Tcl command is invoked
594 that contains the name of the command and its arguments.
595 Setting it to 3 produces a detailed trace showing the result of
596 executing each bytecode instruction.
597 Note that when tcl_traceExec is 2 or 3,
598 commands such as set and incr
599 that have been entirely replaced by a sequence
600 of bytecode instructions are not shown.
601 Setting this variable is useful in
602 tracking down suspected problems with the bytecode compiler
603 and interpreter.
604 It is also occasionally useful when converting
605 code to use Tcl8.0.
607 \fBtcl_wordchars\fR
608 The value of this variable is a regular expression that can be set to
609 control what are considered ``word'' characters, for instances like
610 selecting a word by double-clicking in text in Tk. It is platform
611 dependent. On Windows, it defaults to \fB\\S\fR, meaning anything
612 but a Unicode space character. Otherwise it defaults to \fB\\w\fR,
613 which is any Unicode word character (number, letter, or underscore).
615 \fBtcl_nonwordchars\fR
616 The value of this variable is a regular expression that can be set to
617 control what are considered ``non-word'' characters, for instances like
618 selecting a word by double-clicking in text in Tk. It is platform
619 dependent. On Windows, it defaults to \fB\\s\fR, meaning any Unicode space
620 character. Otherwise it defaults to \fB\\W\fR, which is anything but a
621 Unicode word character (number, letter, or underscore).
623 \fBtcl_version\fR
624 When an interpreter is created Tcl initializes this variable to
625 hold the version number for this version of Tcl in the form \fIx.y\fR.
626 Changes to \fIx\fR represent major changes with probable
627 incompatibilities and changes to \fIy\fR represent small enhancements and
628 bug fixes that retain backward compatibility.
629 The value of this variable is returned by the \fBinfo tclversion\fR
630 command.
632 .SH "SEE ALSO"
633 eval(n)
635 .SH KEYWORDS
636 arithmetic, bytecode, compiler, error, environment, POSIX, precision, subprocess, variables