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 option's (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 isn't specified, returns a list of names of  all  the
34              Tcl commands in the current namespace, including both the built-
35              in commands written in C  and  the  command  procedures  defined
36              using  the  proc  command.   If pattern is specified, only those
37              names matching pattern are  returned.   Matching  is  determined
38              using  the  same  rules  as  for string match.  pattern can be a
39              qualified name like Foo::print*.  That is, it may specify a par‐
40              ticular  namespace using a sequence of namespace names separated
41              by double colons (::), and may  have  pattern  matching  special
42              characters  at  the  end  to  specify  a set of commands in that
43              namespace.  If pattern is a qualified name, the  resulting  list
44              of  command  names  has  each one qualified with the name of the
45              specified namespace.
46
47       info complete command
48              Returns 1 if command is a complete Tcl command in the  sense  of
49              having  no  unclosed  quotes,  braces, brackets or array element
50              names.  If the command doesn't appear to be complete then  0  is
51              returned.  This command is typically used in line-oriented input
52              environments to allow users to type in commands that span multi‐
53              ple  lines;  if the command isn't complete, the script can delay
54              evaluating it until additional lines have been typed to complete
55              the command.
56
57       info default procname arg varname
58              Procname  must  be  the  name of a Tcl command procedure and arg
59              must be the name of an  argument  to  that  procedure.   If  arg
60              doesn't have a default value then the command returns 0.  Other‐
61              wise it returns 1 and places the default value of arg into vari‐
62              able varname.
63
64       info exists varName
65              Returns  1  if  the variable named varName exists in the current
66              context (either as a global or  local  variable)  and  has  been
67              defined by being given a value, returns 0 otherwise.             │
68
69       info functions ?pattern?                                                │
70              If pattern isn't specified, returns a list of all the math func‐ │
71              tions currently defined.  If pattern is  specified,  only  those │
72              functions  whose name matches pattern are returned.  Matching is │
73              determined using the same rules as for string match.
74
75       info globals ?pattern?
76              If pattern isn't specified, returns a list of all the  names  of
77              currently-defined  global variables.  Global variables are vari‐
78              ables in the global namespace.  If pattern  is  specified,  only
79              those  names  matching pattern are returned.  Matching is deter‐
80              mined using the same rules as for string match.
81
82       info hostname
83              Returns the name of the computer on  which  this  invocation  is
84              being executed.  Note that this name is not guaranteed to be the │
85              fully qualified domain name of the host.   Where  machines  have │
86              several  different  names  (as  is  common  on systems with both │
87              TCP/IP (DNS) and NetBIOS-based networking installed,) it is  the │
88              name that is suitable for TCP/IP networking that is returned.
89
90       info level ?number?
91              If number is not specified, this command returns a number giving
92              the stack level of the invoking procedure, or 0 if  the  command
93              is  invoked  at  top-level.   If  number  is specified, then the
94              result is a list consisting of the name and  arguments  for  the
95              procedure call at level number on the stack.  If number is posi‐
96              tive then it selects a particular stack level (1 refers  to  the
97              top-most  active procedure, 2 to the procedure it called, and so
98              on); otherwise it gives a level relative to the current level (0
99              refers  to  the current procedure, -1 to its caller, and so on).
100              See the uplevel command for more information on what stack  lev‐
101              els mean.
102
103       info library
104              Returns  the name of the library directory in which standard Tcl
105              scripts  are  stored.   This  is  actually  the  value  of   the
106              tcl_library  variable and may be changed by setting tcl_library.
107              See the tclvars manual entry for more information.
108
109       info loaded ?interp?
110              Returns a list describing all of the  packages  that  have  been
111              loaded  into interp with the load command.  Each list element is
112              a sub-list with two elements consisting of the name of the  file
113              from  which  the package was loaded and the name of the package.
114              For statically-loaded packages the file name will  be  an  empty
115              string.   If  interp is omitted then information is returned for
116              all packages loaded in any interpreter in the process.  To get a
117              list of just the packages in the current interpreter, specify an
118              empty string for the interp argument.
119
120       info locals ?pattern?
121              If pattern isn't specified, returns a list of all the  names  of
122              currently-defined  local  variables,  including arguments to the
123              current procedure, if any.  Variables defined with  the  global,
124              upvar   and  variable commands will not be returned.  If pattern
125              is specified, only those names matching  pattern  are  returned.
126              Matching is determined using the same rules as for string match.
127
128       info nameofexecutable
129              Returns  the  full  path  name of the binary file from which the
130              application was invoked.  If Tcl  was  unable  to  identify  the
131              file, then an empty string is returned.
132
133       info patchlevel
134              Returns the value of the global variable tcl_patchLevel; see the
135              tclvars manual entry for more information.
136
137       info procs ?pattern?
138              If pattern isn't specified, returns a list of all the  names  of
139              Tcl  command procedures in the current namespace.  If pattern is
140              specified, only those procedure names in the  current  namespace
141              matching pattern are returned.  Matching is determined using the
142              same rules as for string match.  If pattern contains any  names‐
143              pace separators, they are used to select a namespace relative to
144              the current namespace (or relative to the  global  namespace  if
145              pattern starts with ::) to match within; the matching pattern is
146              taken to be the part after the last namespace separator.
147
148       info script ?filename?
149              If a Tcl script file is currently being evaluated (i.e. there is
150              a  call  to Tcl_EvalFile active or there is an active invocation
151              of the source command), then this command returns  the  name  of
152              the  innermost  file being processed.  If filename is specified,
153              then the return value of this command will be modified  for  the
154              duration  of the active invocation to return that name.  This is
155              useful in virtual file system applications.  Otherwise the  com‐
156              mand returns an empty string.
157
158       info sharedlibextension
159              Returns  the  extension  used  on this platform for the names of
160              files  containing  shared  libraries  (for  example,  .so  under
161              Solaris).  If shared libraries aren't supported on this platform
162              then an empty string is returned.
163
164       info tclversion
165              Returns the value of the global variable  tcl_version;  see  the
166              tclvars manual entry for more information.
167
168       info vars ?pattern?
169              If  pattern  isn't specified, returns a list of all the names of
170              currently-visible variables.   This  includes  locals  and  cur‐
171              rently-visible  globals.   If  pattern  is specified, only those
172              names matching pattern are  returned.   Matching  is  determined
173              using  the  same  rules  as  for string match.  pattern can be a
174              qualified name like Foo::option*.  That is,  it  may  specify  a
175              particular  namespace  using a sequence of namespace names sepa‐
176              rated by double colons (::), and may have pattern matching  spe‐
177              cial characters at the end to specify a set of variables in that
178              namespace.  If pattern is a qualified name, the  resulting  list
179              of variable names has each matching namespace variable qualified
180              with the name of its namespace.  Note that  a  currently-visible
181              variable  may  not  yet  "exist"  if it has not been set (e.g. a
182              variable declared but not set by variable).
183

EXAMPLE

185       This command prints out a  procedure  suitable  for  saving  in  a  Tcl
186       script:
187              proc printProc {procName} {
188                  set result [list proc $procName]
189                  set formals {}
190                  foreach var [info args $procName] {
191                      if {[info default $procName $var def]} {
192                          lappend formals [list $var $def]
193                      } else {
194                          # Still need the list-quoting because variable
195                          # names may properly contain spaces.
196                          lappend formals [list $var]
197                      }
198                  }
199                  puts [lappend result $formals [info body $procName]]
200              }
201
202

SEE ALSO

204       global(n), proc(n)
205
206

KEYWORDS

208       command,  information,  interpreter, level, namespace, procedure, vari‐
209       able
210
211
212
213
214Tcl                                   8.4                              info(n)
Impressum