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

INTRODUCTION

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

COMMAND PROCEDURES

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

VARIABLES

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

SEE ALSO

277       info(n), re_syntax(n)
278

KEYWORDS

280       auto-exec, auto-load, library, unknown, word, whitespace
281
282
283
284Tcl                                   8.0                           library(n)
Impressum