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

NAME

8       info - Return information about the state of the Tcl interpreter
9

SYNOPSIS

11       info option ?arg arg ...?
12_________________________________________________________________
13
14

DESCRIPTION

16       This  command  provides  information about various internals of the Tcl
17       interpreter.  The legal options (which may be abbreviated) are:
18
19       info args procname
20              Returns a list containing the names of the arguments  to  proce‐
21              dure  procname,  in  order.   Procname must be the name of a Tcl
22              command procedure.
23
24       info body procname
25              Returns the body of procedure procname.  Procname  must  be  the
26              name of a Tcl command procedure.
27
28       info cmdcount
29              Returns  a  count of the total number of commands that have been
30              invoked in this interpreter.
31
32       info commands ?pattern?
33              If pattern is not specified, returns a list of names of all  the │
34              Tcl  commands visible (i.e. executable without using a qualified │
35              name) to the current namespace, including both the built-in com‐ │
36              mands  written in C and the command procedures defined using the │
37              proc command.  If pattern is specified, only those names  match‐ │
38              ing pattern are returned.  Matching is determined using the same │
39              rules as for string match.  pattern can be a qualified name like │
40              Foo::print*.   That  is,  it  may specify a particular namespace │
41              using a sequence of namespace names separated by  double  colons │
42              (::),  and  may  have pattern matching special characters at the │
43              end to specify a set of commands in that namespace.  If  pattern
44              is  a  qualified  name,  the resulting list of command names has │
45              each one qualified with the name of the specified namespace, and │
46              only the commands defined in the named namespace are returned.
47
48       info complete command
49              Returns  1  if command is a complete Tcl command in the sense of
50              having no unclosed quotes, braces,  brackets  or  array  element
51              names.   If the command does not appear to be complete then 0 is
52              returned.  This command is typically used in line-oriented input
53              environments to allow users to type in commands that span multi‐
54              ple lines;  if the command is not complete, the script can delay
55              evaluating it until additional lines have been typed to complete
56              the command.
57
58       info default procname arg varname
59              Procname must be the name of a Tcl  command  procedure  and  arg
60              must  be the name of an argument to that procedure.  If arg does
61              not have a default value then the command returns 0.   Otherwise
62              it  returns  1 and places the default value of arg into variable
63              varname.
64
65       info exists varName
66              Returns 1 if the variable named varName exists  in  the  current
67              context  (either  as  a  global  or local variable) and has been
68              defined by being given a value, returns 0 otherwise.
69
70       info frame ?number?
71              This command provides access to all frames on  the  stack,  even
72              those  hidden  from info level. If number is not specified, this
73              command returns a number giving the frame level of the  command.
74              This  is  1 if the command is invoked at top-level. If number is
75              specified, then the result is a dictionary containing the  loca‐
76              tion  information  for  the command at the numbered level on the
77              stack.
78
79              If number is positive (> 0) then it selects a  particular  stack
80              level (1 refers to the top-most active command, i.e., info frame
81              itself, 2 to the command it was called from, and so on);  other‐
82              wise  it gives a level relative to the current command (0 refers
83              to the current command, i.e., info frame itself, -1 to its call‐
84              er, and so on).
85
86              This  is  similar to how info level works, except that this sub‐
87              command  reports  all  frames,  like  sourced  scripts,   evals,
88              uplevels, etc.
89
90              Note  that  for  nested commands, like “foo [bar [x]]”, only “x”
91              will be seen by an info frame invoked within “x”.  This  is  the
92              same as for info level and error stack traces.
93
94              The  result  dictionary  may contain the keys listed below, with
95              the specified meanings for their values:
96
97              type   This entry is always present and describes the nature  of
98                     the  location  for the command. The recognized values are
99                     source, proc, eval, and precompiled.
100
101                     source
102                            means that the command is found in a script loaded
103                            by the source command.
104
105                     proc
106                            means  that  the  command  is found in dynamically
107                            created procedure body.
108
109                     eval
110                            means that the command  is  executed  by  eval  or
111                            uplevel.
112
113                     precompiled
114                            means  that  the command is found in a precompiled
115                            script (loadable by the package tbcload),  and  no
116                            further information will be available.
117
118              line   This entry provides the number of the line the command is
119                     at inside of the script it is a part of. This information
120                     is not present for type precompiled. For type source this
121                     information is counted relative to the beginning  of  the
122                     file,  whereas for the last two types the line is counted
123                     relative to the start of the script.
124
125              file   This entry is present only for type source.  It  provides
126                     the normalized path of the file the command is in.
127
128              cmd    This entry provides the string representation of the com‐
129                     mand. This is usually the unsubstituted form, however for
130                     commands which are a pure list executed by eval it is the
131                     substituted form as they have no other string representa‐
132                     tion.  Care  is  taken that the pure-List property of the
133                     latter is not spoiled.
134
135              proc   This entry is present only if the command is found in the
136                     body  of  a  regular  Tcl procedure. It then provides the
137                     name of that procedure.
138
139              lambda This entry is present only if the command is found in the
140                     body  of  an  anonymous  Tcl procedure, i.e. a lambda. It
141                     then provides the entire  definition  of  the  lambda  in
142                     question.
143
144              level  This  entry  is  present  only if the queried frame has a
145                     corresponding frame returned by info level.  It  provides
146                     the index of this frame, relative to the current level (0
147                     and negative numbers).
148
149              A thing of note is that for  procedures  statically  defined  in
150              files the locations of commands in their bodies will be reported
151              with type source and absolute line  numbers,  and  not  as  type
152              proc.  The  same  is  true  for  procedures nested in statically
153              defined procedures, and literal eval scripts in files or  stati‐
154              cally defined procedures.
155
156              In contrast, a procedure definition or eval within a dynamically
157              evaluated environment count linenumbers relative to the start of
158              their  script,  even  if they would be able to count relative to
159              the start of the outer dynamic script. That type of number  usu‐
160              ally makes more sense.
161
162              A  different way of describing this behaviour is that file based
163              locations are tracked as deeply as possible, and where  this  is
164              not  possible the lines are counted based on the smallest possi‐
165              ble eval or procedure body, as that scope is usually  easier  to
166              find than any dynamic outer scope.
167
168              The syntactic form {*} is handled like eval. I.e. if it is given
169              a literal list argument the system tracks the linenumber  within
170              the  list  words  as  well,  and  otherwise  all linenumbers are
171              counted relative to the start of each word (smallest scope)
172
173       info functions ?pattern?
174              If pattern is not specified, returns a  list  of  all  the  math
175              functions  currently  defined.   If  pattern  is specified, only
176              those functions whose name matches pattern are returned.  Match‐
177              ing is determined using the same rules as for string match.
178
179       info globals ?pattern?
180              If  pattern is not specified, returns a list of all the names of
181              currently-defined global variables.  Global variables are  vari‐
182              ables  in  the  global namespace.  If pattern is specified, only
183              those names matching pattern are returned.  Matching  is  deter‐
184              mined using the same rules as for string match.
185
186       info hostname
187              Returns  the  name  of  the computer on which this invocation is
188              being executed.  Note that this name is not guaranteed to be the
189              fully  qualified  domain  name of the host.  Where machines have
190              several different names (as  is  common  on  systems  with  both
191              TCP/IP  (DNS) and NetBIOS-based networking installed,) it is the
192              name that is suitable for TCP/IP networking that is returned.
193
194       info level ?number?
195              If number is not specified, this command returns a number giving
196              the  stack  level of the invoking procedure, or 0 if the command
197              is invoked at top-level.   If  number  is  specified,  then  the
198              result  is  a  list consisting of the name and arguments for the
199              procedure call at level number on the stack.  If number is posi‐
200              tive  then  it selects a particular stack level (1 refers to the
201              top-most active procedure, 2 to the procedure it called, and  so
202              on); otherwise it gives a level relative to the current level (0
203              refers to the current procedure, -1 to its caller, and  so  on).
204              See  the uplevel command for more information on what stack lev‐
205              els mean.
206
207       info library
208              Returns the name of the library directory in which standard  Tcl
209              scripts   are  stored.   This  is  actually  the  value  of  the
210              tcl_library variable and may be changed by setting  tcl_library.
211              See the tclvars manual entry for more information.
212
213       info loaded ?interp?
214              Returns  a  list  describing  all of the packages that have been
215              loaded into interp with the load command.  Each list element  is
216              a  sub-list with two elements consisting of the name of the file
217              from which the package was loaded and the name of  the  package.
218              For  statically-loaded  packages  the file name will be an empty
219              string.  If interp is omitted then information is  returned  for
220              all packages loaded in any interpreter in the process.  To get a
221              list of just the packages in the current interpreter, specify an
222              empty string for the interp argument.
223
224       info locals ?pattern?
225              If  pattern is not specified, returns a list of all the names of
226              currently-defined local variables, including  arguments  to  the
227              current  procedure,  if any.  Variables defined with the global,
228              upvar  and variable commands will not be returned.   If  pattern
229              is  specified,  only  those names matching pattern are returned.
230              Matching is determined using the same rules as for string match.
231
232       info nameofexecutable
233              Returns the full path name of the binary  file  from  which  the
234              application  was  invoked.   If  Tcl  was unable to identify the
235              file, then an empty string is returned.
236
237       info patchlevel
238              Returns the value of the global variable tcl_patchLevel; see the
239              tclvars manual entry for more information.
240
241       info procs ?pattern?
242              If  pattern is not specified, returns a list of all the names of
243              Tcl command procedures in the current namespace.  If pattern  is
244              specified,  only  those procedure names in the current namespace
245              matching pattern are returned.  Matching is determined using the
246              same  rules as for string match.  If pattern contains any names‐
247              pace separators, they are used to select a namespace relative to
248              the  current  namespace  (or relative to the global namespace if
249              pattern starts with ::) to match within; the matching pattern is
250              taken to be the part after the last namespace separator.
251
252       info script ?filename?
253              If a Tcl script file is currently being evaluated (i.e. there is
254              a call to Tcl_EvalFile active or there is an  active  invocation
255              of  the  source  command), then this command returns the name of
256              the innermost file being processed.  If filename  is  specified,
257              then  the  return value of this command will be modified for the
258              duration of the active invocation to return that name.  This  is
259              useful  in virtual file system applications.  Otherwise the com‐
260              mand returns an empty string.
261
262       info sharedlibextension
263              Returns the extension used on this platform  for  the  names  of
264              files  containing  shared  libraries  (for  example,  .so  under
265              Solaris).  If shared libraries are not supported on  this  plat‐
266              form then an empty string is returned.
267
268       info tclversion
269              Returns  the  value  of the global variable tcl_version; see the
270              tclvars manual entry for more information.
271
272       info vars ?pattern?
273              If pattern is not specified, returns a list of all the names  of
274              currently-visible  variables.   This  includes  locals  and cur‐
275              rently-visible globals.  If pattern  is  specified,  only  those
276              names  matching  pattern  are  returned.  Matching is determined
277              using the same rules as for string  match.   pattern  can  be  a
278              qualified  name  like  Foo::option*.   That is, it may specify a
279              particular namespace using a sequence of namespace  names  sepa‐
280              rated  by double colons (::), and may have pattern matching spe‐
281              cial characters at the end to specify a set of variables in that
282              namespace.   If  pattern is a qualified name, the resulting list
283              of variable names has each matching namespace variable qualified
284              with  the  name of its namespace.  Note that a currently-visible
285              variable may not yet “exist” if it has  not  been  set  (e.g.  a
286              variable declared but not set by variable).
287

EXAMPLE

289       This  command  prints  out  a  procedure  suitable  for saving in a Tcl
290       script:
291
292              proc printProc {procName} {
293                  set result [list proc $procName]
294                  set formals {}
295                  foreach var [info args $procName] {
296                      if {[info default $procName $var def]} {
297                          lappend formals [list $var $def]
298                      } else {
299                          # Still need the list-quoting because variable
300                          # names may properly contain spaces.
301                          lappend formals [list $var]
302                      }
303                  }
304                  puts [lappend result $formals [info body $procName]]
305              }
306

SEE ALSO

308       global(n), proc(n)
309

KEYWORDS

311       command, information, interpreter, level, namespace,  procedure,  vari‐
312       able
313
314
315
316Tcl                                   8.4                              info(n)
Impressum