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

NAME

8       auto_execok,   auto_import,   auto_load,   auto_mkindex,  auto_qualify,
9       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_qualify command namespace
19       auto_reset
20       tcl_findLibrary basename version patch initScript enVarName varName
21       parray arrayName ?pattern?
22       tcl_endOfWord str start
23       tcl_startOfNextWord str start
24       tcl_startOfPreviousWord str start
25       tcl_wordBreakAfter str start
26       tcl_wordBreakBefore str start
27______________________________________________________________________________
28

INTRODUCTION

30       Tcl includes a library of Tcl procedures for commonly-needed functions.
31       The procedures defined in the Tcl library are generic ones suitable for
32       use by many different applications.  The location of the Tcl library is
33       returned  by the info library command.  In addition to the Tcl library,
34       each application will normally have its own library of  support  proce‐
35       dures  as  well;  the location of this library is normally given by the
36       value of the $app_library global variable, where app is the name of the
37       application.   For  example,  the location of the Tk library is kept in
38       the variable tk_library.
39
40       To access the procedures in the  Tcl  library,  an  application  should
41       source  the file init.tcl in the library, for example with the Tcl com‐
42       mand
43
44              source [file join [info library] init.tcl]
45
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

COMMAND PROCEDURES

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

VARIABLES

222       The following global variables are defined or used by the procedures in
223       the Tcl library. They fall into two  broad  classes,  handling  unknown
224       commands and packages, and determining what are words.
225
226   AUTOLOADING AND PACKAGE MANAGEMENT VARIABLES
227       auto_execs
228              Used by auto_execok to record information about whether particu‐
229              lar commands exist as executable files.
230
231       auto_index
232              Used by auto_load to save the index information read from disk.
233
234       auto_noexec
235              If set to any value, then unknown will not attempt to  auto-exec
236              any commands.
237
238       auto_noload
239              If  set to any value, then unknown will not attempt to auto-load
240              any commands.
241
242       auto_path
243              If set, then it must contain a valid Tcl list giving directories
244              to search during auto-load operations (including for package in‐
245              dex files when using the default package unknown handler).  This
246              variable is initialized during startup to contain, in order: the
247              directories listed in the TCLLIBPATH environment  variable,  the
248              directory  named  by the tcl_library global variable, the parent
249              directory of tcl_library, the directories listed in the tcl_pkg‐
250              Path variable.  Additional locations to look for files and pack‐
251              age indices should normally be added to this variable using lap‐
252              pend.
253
254       env(TCL_LIBRARY)
255              If set, then it specifies the location of the directory contain‐
256              ing library scripts (the value of this variable will be assigned
257              to  the  tcl_library variable and therefore returned by the com‐
258              mand info library).  If this variable is not set then a  default
259              value is used.
260
261       env(TCLLIBPATH)
262              If set, then it must contain a valid Tcl list giving directories
263              to search during  auto-load  operations.   Directories  must  be
264              specified  in  Tcl  format, using “/” as the path separator, re‐
265              gardless of platform.  This variable is only used when  initial‐
266              izing the auto_path variable.
267
268   WORD BOUNDARY DETERMINATION VARIABLES
269       These    variables    are    only    used    in    the   tcl_endOfWord,
270       tcl_startOfNextWord, tcl_startOfPreviousWord,  tcl_wordBreakAfter,  and
271       tcl_wordBreakBefore commands.
272
273       tcl_nonwordchars
274              This variable contains a regular expression that is used by rou‐
275              tines like tcl_endOfWord to identify whether a character is part
276              of a word or not.  If the pattern matches a character, the char‐
277              acter is considered to be  a  non-word  character.   On  Windows
278              platforms,  spaces,  tabs,  and newlines are considered non-word
279              characters.  Under Unix, everything but numbers, letters and un‐
280              derscores are considered non-word characters.
281
282       tcl_wordchars
283              This variable contains a regular expression that is used by rou‐
284              tines like tcl_endOfWord to identify whether a character is part
285              of a word or not.  If the pattern matches a character, the char‐
286              acter is considered to be a word character.   On  Windows  plat‐
287              forms, words are comprised of any character that is not a space,
288              tab, or newline.  Under Unix, words are  comprised  of  numbers,
289              letters or underscores.
290

SEE ALSO

292       env(n), info(n), re_syntax(n)
293

KEYWORDS

295       auto-exec, auto-load, library, unknown, word, whitespace
296
297
298
299Tcl                                   8.0                           library(n)
Impressum