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

NAME

8       auto_execok,  auto_import,  auto_load,  auto_mkindex, auto_mkindex_old,
9       auto_qualify,  auto_reset,  tcl_findLibrary,   parray,   tcl_endOfWord,
10       tcl_startOfNextWord,    tcl_startOfPreviousWord,    tcl_wordBreakAfter,
11       tcl_wordBreakBefore - standard library of Tcl procedures
12

SYNOPSIS

14       auto_execok cmd
15       auto_import pattern
16       auto_load cmd
17       auto_mkindex dir pattern pattern ...
18       auto_mkindex_old dir pattern pattern ...
19       auto_qualify command namespace
20       auto_reset
21       tcl_findLibrary basename version patch initScript enVarName varName
22       parray arrayName
23       tcl_endOfWord str start
24       tcl_startOfNextWord str start
25       tcl_startOfPreviousWord str start
26       tcl_wordBreakAfter str start
27       tcl_wordBreakBefore str start
28_________________________________________________________________
29
30

INTRODUCTION

32       Tcl includes a library of Tcl procedures for commonly-needed functions.
33       The procedures defined in the Tcl library are generic ones suitable for
34       use by many different applications.  The location of the Tcl library is
35       returned  by the info library command.  In addition to the Tcl library,
36       each application will normally have its own library of  support  proce‐
37       dures  as  well;  the location of this library is normally given by the
38       value of the $app_library global variable, where app is the name of the
39       application.   For  example,  the location of the Tk library is kept in
40       the variable $tk_library.
41
42       To access the procedures in the  Tcl  library,  an  application  should
43       source  the file init.tcl in the library, for example with the Tcl com‐
44       mand
45              source [file join [info library] init.tcl]
46       If the library procedure Tcl_Init  is  invoked  from  an  application's
47       Tcl_AppInit   procedure,  this  happens  automatically.   The  code  in
48       init.tcl will define the unknown procedure and arrange  for  the  other
49       procedures to be loaded on-demand using the auto-load mechanism defined
50       below.
51
52

COMMAND PROCEDURES

54       The following procedures are provided in the Tcl library:
55
56       auto_execok cmd
57              Determines whether there is an executable file or shell  builtin
58              by  the  name  cmd.  If so, it returns a list of arguments to be
59              passed to exec to execute the executable file or  shell  builtin
60              named by cmd.  If not, it returns an empty string.  This command
61              examines the directories in the current search  path  (given  by
62              the  PATH  environment variable) in its search for an executable
63              file named cmd.  On Windows platforms, the  search  is  expanded
64              with  the  same directories and file extensions as used by exec.
65              Auto_exec remembers information about previous  searches  in  an
66              array  named  auto_execs;  this avoids the path search in future
67              calls for the same cmd.  The command auto_reset may be  used  to
68              force auto_execok to forget its cached information.
69
70       auto_import pattern
71              Auto_import  is  invoked  during  namespace import to see if the
72              imported commands specified by pattern reside in  an  autoloaded
73              library.   If  so,  the commands are loaded so that they will be
74              available to the interpreter for creating the import links.   If
75              the commands do not reside in an autoloaded library, auto_import
76              does nothing.  The pattern matching is  performed  according  to
77              the matching rules of namespace import.
78
79       auto_load cmd
80              This  command  attempts to load the definition for a Tcl command
81              named cmd.  To do this, it searches an auto-load path, which  is
82              a  list of one or more directories.  The auto-load path is given
83              by the global variable $auto_path if it exists.  If there is  no
84              $auto_path variable, then the TCLLIBPATH environment variable is
85              used, if it exists.  Otherwise the auto-load  path  consists  of
86              just  the  Tcl  library directory.  Within each directory in the
87              auto-load path there must be a file tclIndex that describes  one
88              or more commands defined in that directory and a script to eval‐
89              uate to load each of the commands.  The tclIndex file should  be
90              generated  with the auto_mkindex command.  If cmd is found in an
91              index file, then the appropriate script is evaluated  to  create
92              the  command.   The  auto_load command returns 1 if cmd was suc‐
93              cessfully created.  The command returns 0 if there was no  index
94              entry  for cmd or if the script didn't actually define cmd (e.g.
95              because index information is out of date).  If an  error  occurs
96              while  processing  the  script,  then  that  error  is returned.
97              Auto_load only reads the index information once and saves it  in
98              the  array  auto_index;  future calls to auto_load check for cmd
99              in the array rather than re-reading the index files.  The cached
100              index  information  may  be deleted with the command auto_reset.
101              This will force the next auto_load command to reload  the  index
102              database from disk.
103
104       auto_mkindex dir pattern pattern ...
105              Generates  an  index suitable for use by auto_load.  The command
106              searches dir for all files whose names match any of the  pattern
107              arguments (matching is done with the glob command), generates an
108              index of all the Tcl  command  procedures  defined  in  all  the
109              matching files, and stores the index information in a file named
110              tclIndex in dir. If no pattern is given a pattern of *.tcl  will
111              be assumed.  For example, the command
112                     auto_mkindex foo *.tcl
113
114              will  read all the .tcl files in subdirectory foo and generate a
115              new index file foo/tclIndex.
116
117              Auto_mkindex parses the Tcl scripts  by  sourcing  them  into  a
118              slave interpreter and monitoring the proc and namespace commands
119              that  are  executed.   Extensions  can  use  the  (undocumented)
120              auto_mkindex_parser  package to register other commands that can
121              contribute to the auto_load index. You will have to read through
122              auto.tcl to see how this works.
123
124              Auto_mkindex_old  parses  the  Tcl scripts in a relatively unso‐
125              phisticated way:  if any line contains  the  word  proc  as  its
126              first characters then it is assumed to be a procedure definition
127              and the next word of the line is taken as the procedure's  name.
128              Procedure  definitions  that don't appear in this way (e.g. they
129              have spaces before the proc)  will  not  be  indexed.   If  your
130              script  contains "dangerous" code, such as global initialization
131              code or procedure names with special characters like $, *, [  or
132              ], you are safer using auto_mkindex_old.
133
134       auto_reset
135              Destroys   all   the   information  cached  by  auto_execok  and
136              auto_load.  This information will be re-read from disk the  next
137              time  it  is  needed.   Auto_reset  also  deletes any procedures
138              listed in the auto-load index, so that fresh copies of them will
139              be loaded the next time that they're used.
140
141       auto_qualify command namespace
142              Computes a list of fully qualified names for command.  This list
143              mirrors the path a standard Tcl interpreter follows for  command
144              lookups:   first  it looks for the command in the current names‐
145              pace, and then in the global namespace.  Accordingly, if command
146              is  relative  and namespace is not ::, the list returned has two
147              elements:  command scoped by namespace, as if it were a  command
148              in  the namespace namespace; and command as if it were a command
149              in the global namespace.  Otherwise, if either command is  abso‐
150              lute  (it begins with ::), or namespace is ::, the list contains
151              only command as if it were a command in the global namespace.
152
153              Auto_qualify is used by the auto-loading facilities in Tcl, both
154              for producing auto-loading indexes such as pkgIndex.tcl, and for
155              performing the actual auto-loading of functions at runtime.
156
157       tcl_findLibrary basename version patch initScript enVarName varName
158              This is a standard search procedure for use by extensions during
159              their  initialization.   They  call  this  procedure to look for
160              their script library in several standard directories.  The  last
161              component of the name of the library directory is normally base‐
162              nameversion (e.g., tk8.0), but it might be "library" when in the
163              build hierarchies.  The initScript file will be sourced into the
164              interpreter once it is found.  The directory in which this  file
165              is  found  is  stored into the global variable varName.  If this
166              variable is already defined (e.g., by C code during  application
167              initialization) then no searching is done.  Otherwise the search
168              looks in these directories: the directory named by the  environ‐
169              ment  variable enVarName; relative to the Tcl library directory;
170              relative to the executable file in the standard installation bin
171              or  bin/arch  directory;  relative to the executable file in the
172              current build tree; relative to the executable file in a  paral‐
173              lel build tree.
174
175       parray arrayName
176              Prints  on  standard output the names and values of all the ele‐
177              ments in the array arrayName.  ArrayName must be an array acces‐
178              sible  to  the  caller  of  parray.   It  may be either local or
179              global.
180
181       tcl_endOfWord str start
182              Returns the index of the first end-of-word location that  occurs │
183              after  a starting index start in the string str.  An end-of-word │
184              location is defined to be the first non-word character following │
185              the  first  word character after the starting point.  Returns -1 │
186              if there are no more end-of-word locations  after  the  starting │
187              point.   See  the  description of tcl_wordchars and tcl_nonword‐ 
188              chars below for more details on how Tcl determines which charac‐ │
189              ters are word characters.                                        │
190
191       tcl_startOfNextWord str start
192              Returns  the  index  of  the  first  start-of-word location that │
193              occurs after a starting index start in the string str.  A start- │
194              of-word  location is defined to be the first word character fol‐ │
195              lowing a non-word character.  Returns -1 if there  are  no  more │
196              start-of-word locations after the starting point.                │
197
198       tcl_startOfPreviousWord str start
199              Returns  the  index  of  the  first  start-of-word location that │
200              occurs before a starting index start in the string str.  Returns │
201              -1  if  there  are  no  more  start-of-word locations before the │
202              starting point.                                                  │
203
204       tcl_wordBreakAfter str start
205              Returns the index of the first word boundary after the  starting │
206              index  start in the string str.  Returns -1 if there are no more │
207              boundaries after the starting point in the  given  string.   The │
208              index  returned  refers to the second character of the pair that │
209              comprises a boundary.                                            │
210
211       tcl_wordBreakBefore str start
212              Returns the index of the first word boundary before the starting │
213              index  start in the string str.  Returns -1 if there are no more │
214              boundaries before the starting point in the given  string.   The │
215              index  returned  refers to the second character of the pair that │
216              comprises a boundary.
217
218

VARIABLES

220       The following global variables are defined or used by the procedures in
221       the Tcl library:
222
223       auto_execs
224              Used by auto_execok to record information about whether particu‐
225              lar commands exist as executable files.
226
227       auto_index
228              Used by auto_load to save the index information read from disk.
229
230       auto_noexec
231              If set to any value, then unknown will not attempt to  auto-exec
232              any commands.
233
234       auto_noload
235              If  set to any value, then unknown will not attempt to auto-load
236              any commands.
237
238       auto_path
239              If set, then it must contain a valid Tcl list giving directories
240              to  search  during  auto-load operations.  This variable is ini‐
241              tialized during startup to contain, in  order:  the  directories
242              listed  in  the  TCLLIBPATH  environment variable, the directory
243              named by the $tcl_library  variable,  the  parent  directory  of
244              $tcl_library,  the  directories listed in the $tcl_pkgPath vari‐
245              able.
246
247       env(TCL_LIBRARY)
248              If set, then it specifies the location of the directory contain‐
249              ing library scripts (the value of this variable will be assigned
250              to the tcl_library variable and therefore returned by  the  com‐
251              mand  info  library).  If this variable isn't set then a default
252              value is used.
253
254       env(TCLLIBPATH)
255              If set, then it must contain a valid Tcl list giving directories
256              to  search  during  auto-load  operations.   Directories must be
257              specified in Tcl  format,  using  "/"  as  the  path  separator,
258              regardless  of  platform.   This variable is only used when ini‐
259              tializing the auto_path variable.
260
261       tcl_nonwordchars
262              This variable contains a regular expression that is used by rou‐ │
263              tines like tcl_endOfWord to identify whether a character is part │
264              of a word or not.  If the pattern matches a character, the char‐ │
265              acter  is  considered  to  be  a non-word character.  On Windows │
266              platforms, spaces, tabs, and newlines  are  considered  non-word │
267              characters.   Under  Unix,  everything  but numbers, letters and │
268              underscores are considered non-word characters.                  │
269
270       tcl_wordchars                                                           
271              This variable contains a regular expression that is used by rou‐ │
272              tines like tcl_endOfWord to identify whether a character is part │
273              of a word or not.  If the pattern matches a character, the char‐ │
274              acter  is  considered  to be a word character.  On Windows plat‐ │
275              forms, words are comprised of any character that is not a space, │
276              tab,  or  newline.   Under Unix, words are comprised of numbers, │
277              letters or underscores.
278
279       unknown_pending
280              Used by unknown to record the command(s) for which it is search‐
281              ing.   It  is  used  to  detect errors where unknown recurses on
282              itself  infinitely.   The  variable  is  unset  before   unknown
283              returns.
284
285

SEE ALSO

287       info(n), re_syntax(n)
288
289

KEYWORDS

291       auto-exec, auto-load, library, unknown, word, whitespace
292
293
294
295Tcl                                   8.0                           library(n)
Impressum