1tclvars(n)                   Tcl Built-In Commands                  tclvars(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       tclvars - Variables used by Tcl
9_________________________________________________________________
10
11

DESCRIPTION

13       The following global variables are created and managed automatically by
14       the Tcl library.  Except where noted below, these variables should nor‐
15       mally  be  treated  as  read-only  by  application-specific code and by
16       users.
17
18       env    This variable is maintained by Tcl as an  array  whose  elements
19              are  the environment variables for the process.  Reading an ele‐
20              ment will return the  value  of  the  corresponding  environment
21              variable.   Setting an element of the array will modify the cor‐
22              responding environment variable  or  create  a  new  one  if  it
23              doesn't  already exist.  Unsetting an element of env will remove
24              the corresponding environment  variable.   Changes  to  the  env
25              array will affect the environment passed to children by commands
26              like exec.  If the entire env array is unset then Tcl will  stop
27              monitoring  env  accesses  and will not update environment vari‐
28              ables.
29              Under Windows, the environment variables PATH and COMSPEC in any │
30              capitalization  are  converted automatically to upper case.  For │
31              instance, the PATH variable could be exported by  the  operating │
32              system  as ``path'', ``Path'', ``PaTh'', etc., causing otherwise │
33              simple Tcl code to have to  support  many  special  cases.   All │
34              other  environment  variables  inherited by Tcl are left unmodi‐ │
35              fied.  Setting an env array variable to blank  is  the  same  as │
36              unsetting  it  as this is the behavior of the underlying Windows │
37              OS.  It should be noted that relying on an  existing  and  empty │
38              environment  variable  won't  work on windows and is discouraged │
39              for cross-platform usage.
40              On the Macintosh, the environment variable is constructed by Tcl
41              as no global environment variable exists.  The environment vari‐
42              ables that are created for Tcl include:
43
44              LOGIN  This holds the Chooser name of the Macintosh.
45
46              USER   This also holds the Chooser name of the Macintosh.
47
48              SYS_FOLDER
49                     The path to the system directory.
50
51              APPLE_M_FOLDER
52                     The path to the Apple Menu directory.
53
54              CP_FOLDER
55                     The path to the control panels directory.
56
57              DESK_FOLDER
58                     The path to the desk top directory.
59
60              EXT_FOLDER
61                     The path to the system extensions directory.
62
63              PREF_FOLDER
64                     The path to the preferences directory.
65
66              PRINT_MON_FOLDER
67                     The path to the print monitor directory.
68
69              SHARED_TRASH_FOLDER
70                     The path to the network trash directory.
71
72              TRASH_FOLDER
73                     The path to the trash directory.
74
75              START_UP_FOLDER
76                     The path to the start up directory.
77
78              HOME   The path to the application's default directory.
79
80              You can also create your own environment variables for the  Mac‐
81              intosh.   A  file named  Tcl Environment Variables may be placed
82              in the preferences folder in the Mac system folder.   Each  line
83              of this file should be of the form VAR_NAME=var_data.
84
85              The  last  alternative  is  to  place environment variables in a
86              'STR#' resource named Tcl Environment Variables of the  applica‐
87              tion.  This is considered a little more ``Mac like'' than a Unix
88              style Environment Variable  file.   Each  entry  in  the  'STR#'
89              resource  has  the  same  format as above.  The source code file
90              tclMacEnv.c contains the implementation of the  env  mechanisms.
91              This  file  contains  many #define's that allow customization of
92              the env mechanisms to fit your applications needs.
93
94       errorCode
95              After an error has occurred, this variable will be set to hold a
96              list  value  representing additional information about the error
97              in a form that is easy to process with programs.  The first ele‐
98              ment  of  the  list  identifies  a  general class of errors, and
99              determines the format of the rest of the  list.   The  following
100              formats  for  errorCode  are  used  by  the Tcl core; individual
101              applications may define additional formats.
102
103              ARITH code msg
104                     This format is used when an arithmetic error occurs (e.g.
105                     an  attempt to divide by zero in the expr command).  Code
106                     identifies the precise error and msg  provides  a  human-
107                     readable  description  of the error.  Code will be either
108                     DIVZERO (for an attempt to divide by zero), DOMAIN (if an
109                     argument  is  outside  the  domain of a function, such as
110                     acos(-3)), IOVERFLOW  (for  integer  overflow),  OVERFLOW
111                     (for a floating-point overflow), or UNKNOWN (if the cause
112                     of the error cannot be determined).
113
114              CHILDKILLED pid sigName msg
115                     This format is used when a child process has been  killed
116                     because  of  a  signal.   The second element of errorCode
117                     will be the process's identifier (in decimal).  The third
118                     element  will  be  the  symbolic  name of the signal that
119                     caused the process to terminate; it will be  one  of  the
120                     names  from  the  include file signal.h, such as SIGPIPE.
121                     The fourth element will be a short human-readable message
122                     describing  the  signal,  such as ``write on pipe with no
123                     readers'' for SIGPIPE.
124
125              CHILDSTATUS pid code
126                     This format is used when a child process has exited  with
127                     a  non-zero exit status.  The second element of errorCode
128                     will be the process's identifier  (in  decimal)  and  the
129                     third  element  will  be  the  exit  code returned by the
130                     process (also in decimal).
131
132              CHILDSUSP pid sigName msg
133                     This format is used when a child process  has  been  sus‐
134                     pended because of a signal.  The second element of error‐
135                     Code will be the process's identifier, in  decimal.   The
136                     third  element  will  be  the symbolic name of the signal
137                     that caused the process to suspend; this will be  one  of
138                     the  names  from the include file signal.h, such as SIGT‐
139                     TIN.  The fourth element will be a  short  human-readable
140                     message  describing  the signal, such as ``background tty
141                     read'' for SIGTTIN.
142
143              NONE   This format is used for errors where no additional infor‐
144                     mation  is  available  for  an  error besides the message
145                     returned with the error.  In these cases  errorCode  will
146                     consist  of a list containing a single element whose con‐
147                     tents are NONE.
148
149              POSIX errName msg
150                     If the first element of  errorCode  is  POSIX,  then  the
151                     error  occurred  during  a POSIX kernel call.  The second
152                     element of the list will contain the symbolic name of the
153                     error  that occurred, such as ENOENT; this will be one of
154                     the values defined in  the  include  file  errno.h.   The
155                     third  element  of the list will be a human-readable mes‐
156                     sage corresponding to errName, such as ``no such file  or
157                     directory'' for the ENOENT case.
158
159              To  set  errorCode,  applications  should use library procedures
160              such as Tcl_SetErrorCode and Tcl_PosixError, or they may  invoke
161              the  error  command.   If one of these methods hasn't been used,
162              then the Tcl interpreter will reset the variable to  NONE  after
163              the next error.
164
165       errorInfo
166              After  an  error  has  occurred, this string will contain one or
167              more lines identifying the Tcl commands and procedures that were
168              being  executed  when  the most recent error occurred.  Its con‐
169              tents take the form of a stack trace showing the various  nested
170              Tcl commands that had been invoked at the time of the error.
171
172       tcl_library
173              This  variable holds the name of a directory containing the sys‐
174              tem library of Tcl scripts, such as those used for auto-loading.
175              The  value of this variable is returned by the info library com‐
176              mand.  See the library manual entry for details of  the  facili‐
177              ties provided by the Tcl script library.  Normally each applica‐
178              tion or package will have its  own  application-specific  script
179              library  in addition to the Tcl script library; each application
180              should set a global  variable  with  a  name  like  $app_library
181              (where  app  is the application's name) to hold the network file
182              name for that  application's  library  directory.   The  initial
183              value  of  tcl_library  is set when an interpreter is created by
184              searching several different directories until one is found  that
185              contains  an appropriate Tcl startup script.  If the TCL_LIBRARY
186              environment variable exists, then  the  directory  it  names  is
187              checked  first.  If TCL_LIBRARY isn't set or doesn't refer to an
188              appropriate directory, then Tcl checks several other directories
189              based  on  a  compiled-in  default location, the location of the
190              binary containing  the  application,  and  the  current  working
191              directory.
192
193       tcl_patchLevel
194              When  an interpreter is created Tcl initializes this variable to
195              hold a string giving the current patch level for  Tcl,  such  as
196              7.3p2  for Tcl 7.3 with the first two official patches, or 7.4b4
197              for the fourth beta release of Tcl 7.4.  The value of this vari‐
198              able is returned by the info patchlevel command.
199
200       tcl_pkgPath                                                             
201              This variable holds a list of directories indicating where pack‐ │
202              ages are normally installed.  It is not  used  on  Windows.   It │
203              typically contains either one or two entries; if it contains two │
204              entries, the first is normally a directory  for  platform-depen‐ │
205              dent  packages (e.g., shared library binaries) and the second is │
206              normally a directory for  platform-independent  packages  (e.g., │
207              script  files).  Typically a package is installed as a subdirec‐ │
208              tory of one of the entries in $tcl_pkgPath. The  directories  in │
209              $tcl_pkgPath  are included by default in the auto_path variable, │
210              so they and their  immediate  subdirectories  are  automatically │
211              searched  for  packages  during package require commands.  Note: │
212              tcl_pkgPath it not intended to be modified by  the  application. │
213              Its  value is added to auto_path at startup; changes to tcl_pkg‐ 
214              Path are not reflected in auto_path.  If you want Tcl to  search │
215              additional  directories for packages you should add the names of │
216              those directories to auto_path, not tcl_pkgPath.
217
218       tcl_platform
219              This is an associative array whose elements contain  information
220              about  the platform on which the application is running, such as
221              the name of the operating system, its  current  release  number,
222              and  the  machine's  instruction set.  The elements listed below
223              will always be defined, but they may have empty strings as  val‐
224              ues if Tcl couldn't retrieve any relevant information.  In addi‐
225              tion, extensions and applications may add additional  values  to
226              the array.  The predefined elements are:
227
228              byteOrder                                                        
229                     The  native  byte order of this machine: either littleEn‐ 
230                     dian or bigEndian.
231
232              debug  If this variable exists, then the  interpreter  was  com‐
233                     piled  with  and  linked  to  a debug-enabled C run-time.
234                     This variable will only exist on  Windows,  so  extension
235                     writers  can  specify  which package to load depending on
236                     the C run-time library that is in use.  This  is  not  an
237                     indication that this core contains symbols.
238
239              machine
240                     The  instruction  set  executed  by this machine, such as
241                     intel, PPC, 68k, or sun4m.  On UNIX machines, this is the
242                     value returned by uname -m.
243
244              os     The name of the operating system running on this machine,
245                     such as Windows 95, Windows NT, MacOS, or SunOS.  On UNIX
246                     machines,  this  is  the  value returned by uname -s.  On
247                     Windows 95 and Windows 98, the  value  returned  will  be
248                     Windows  95  to provide better backwards compatibility to
249                     Windows 95; to distinguish between  the  two,  check  the
250                     osVersion.
251
252              osVersion
253                     The  version  number  for the operating system running on
254                     this machine.   On  UNIX  machines,  this  is  the  value
255                     returned by uname -r.  On Windows 95, the version will be
256                     4.0; on Windows 98, the version will be 4.10.
257
258              platform
259                     Either windows, macintosh, or unix.  This identifies  the
260                     general operating environment of the machine.
261
262              threaded
263                     If  this  variable  exists, then the interpreter was com‐
264                     piled with threads enabled.
265
266              user   This identifies the  current  user  based  on  the  login
267                     information  available  on the platform.  This comes from
268                     the USER or LOGNAME environment variable on Unix, and the
269                     value from GetUserName on Windows and Macintosh.
270
271              wordSize
272                     This  gives  the size of the native-machine word in bytes │
273                     (strictly,  it  is  same  as  the  result  of  evaluating │
274                     sizeof(long) in C.)
275
276       tcl_precision
277              This  variable  controls  the  number of digits to generate when │
278              converting floating-point values to strings.  It defaults to 12. │
279              17  digits  is  ``perfect''  for  IEEE floating-point in that it │
280              allows double-precision values to be converted  to  strings  and │
281              back  to  binary with no loss of information.  However, using 17 │
282              digits prevents any rounding, which produces longer, less  intu‐ │
283              itive results.  For example, expr 1.4 returns 1.3999999999999999 │
284              with tcl_precision set to 17, vs. 1.4 if tcl_precision is 12.    │
285              All interpreters in  a  process  share  a  single  tcl_precision 
286              value:  changing  it  in  one  interpreter will affect all other │
287              interpreters  as  well.   However,  safe  interpreters  are  not │
288              allowed to modify the variable.                                  │
289
290       tcl_rcFileName
291              This variable is used during initialization to indicate the name
292              of a user-specific startup file.  If it is set  by  application-
293              specific  initialization,  then  the Tcl startup code will check
294              for the existence of this file and source it if it exists.   For
295              example,  for wish the variable is set to ~/.wishrc for Unix and
296              ~/wishrc.tcl for Windows.
297
298       tcl_rcRsrcName
299              This variable is only used on Macintosh systems.   The  variable
300              is  used  during  initialization to indicate the name of a user-
301              specific TEXT resource located in the application  or  extension
302              resource  forks.   If it is set by application-specific initial‐
303              ization, then the Tcl startup code will check for the  existence
304              of  this  resource and source it if it exists.  For example, the
305              Macintosh wish application has the variable is set to tclshrc.
306
307       tcl_traceCompile
308              The value of this variable can be set to control how much  trac‐
309              ing  information  is  displayed during bytecode compilation.  By
310              default, tcl_traceCompile is zero and  no  information  is  dis‐
311              played.  Setting tcl_traceCompile to 1 generates a one-line sum‐
312              mary in stdout whenever a procedure or top-level command is com‐
313              piled.   Setting  it to 2 generates a detailed listing in stdout
314              of the bytecode instructions emitted during  every  compilation.
315              This variable is useful in tracking down suspected problems with
316              the Tcl compiler.  It is also occasionally useful when  convert‐
317              ing existing code to use Tcl8.0.
318
319       This  variable  and  functionality  only exist if TCL_COMPILE_DEBUG was
320       defined during Tcl's compilation.
321
322       tcl_traceExec
323              The value of this variable can be set to control how much  trac‐
324              ing  information  is  displayed  during  bytecode execution.  By
325              default, tcl_traceExec is zero and no information is  displayed.
326              Setting  tcl_traceExec to 1 generates a one-line trace in stdout
327              on each call to a Tcl procedure.  Setting it to  2  generates  a
328              line of output whenever any Tcl command is invoked that contains
329              the name of the command and its arguments.  Setting it to 3 pro‐
330              duces  a  detailed  trace  showing  the result of executing each
331              bytecode instruction.  Note that when tcl_traceExec is 2  or  3,
332              commands  such  as set and incr that have been entirely replaced
333              by a sequence of bytecode instructions are not  shown.   Setting
334              this variable is useful in tracking down suspected problems with
335              the bytecode compiler and interpreter.  It is also  occasionally
336              useful when converting code to use Tcl8.0.
337
338       This  variable  and  functionality  only exist if TCL_COMPILE_DEBUG was
339       defined during Tcl's compilation.
340
341       tcl_wordchars
342              The value of this variable is a regular expression that  can  be
343              set  to  control  what  are  considered ``word'' characters, for
344              instances like selecting a word by double-clicking  in  text  in
345              Tk.   It  is platform dependent.  On Windows, it defaults to \S,
346              meaning anything but a Unicode space  character.   Otherwise  it
347              defaults  to  \w,  which  is any Unicode word character (number,
348              letter, or underscore).
349
350       tcl_nonwordchars
351              The value of this variable is a regular expression that  can  be
352              set  to control what are considered ``non-word'' characters, for
353              instances like selecting a word by double-clicking  in  text  in
354              Tk.   It  is platform dependent.  On Windows, it defaults to \s,
355              meaning any Unicode space character.  Otherwise it  defaults  to
356              \W, which is anything but a Unicode word character (number, let‐
357              ter, or underscore).
358
359       tcl_version
360              When an interpreter is created Tcl initializes this variable  to
361              hold the version number for this version of Tcl in the form x.y.
362              Changes to x represent major changes with probable incompatibil‐
363              ities  and  changes  to  y  represent small enhancements and bug
364              fixes that retain backward compatibility.   The  value  of  this
365              variable is returned by the info tclversion command.
366

OTHER GLOBAL VARIABLES

368       The  following variables are only guaranteed to exist in tclsh and wish
369       executables; the Tcl library does not define them itself but  many  Tcl
370       environments do.
371
372       argc  The number of arguments to tclsh or wish.
373
374       argv  Tcl list of arguments to tclsh or wish.
375
376       argv0 The script that tclsh or wish started executing (if it was speci‐
377             fied) or otherwise the name by which tclsh or wish was invoked.
378
379       tcl_interactive
380             Contains 1 if tclsh or wish is running interactively  (no  script
381             was  specified  and  standard input is a terminal-like device), 0
382             otherwise.
383
384       The wish executably additionally specifies the following  global  vari‐
385       able:
386
387       geometry
388             If  set, contains the user-supplied geometry specification to use
389             for the main Tk window.
390
391

SEE ALSO

393       eval(n), tclsh(1), wish(1)
394
395

KEYWORDS

397       arithmetic, bytecode, compiler, error, environment,  POSIX,  precision,
398       subprocess, variables
399
400
401
402Tcl                                   8.0                           tclvars(n)
Impressum