Table of Contents
There are a number of subcommands to the info command that provide information about the
current state of the interpreter. These commands provide access to
information like the current version and patchlevel, what script is
currently being executed, how many commands have been executed, or
how far down in the call tree the current proc is executing.
The info tclversion and info
patchlevel can be used to find out if the
revision level of the interpreter running your code has the support
for features you are using. If you know that certain features are
not available in certain revisions of the interpreter, you can
define your own procs to handle this, or just exit the program with
an error message.
The info cmdcount and info
level can be used while optimizing a Tcl
script to find out how many levels and commands were necessary to
accomplish a function.
Note that the pid command is not
part of the info command, but a
command in its own right.
Subcommands that return information about the current state of the interpreter
(Note: There are several other subcommands that can be useful at times)
info cmdcountReturns the total number of commands that have been executed by this interpreter.
info level ?number?Returns the stack level at which the compiler is currently evaluating code. 0 is the top level, 1 is a proc called from top, 2 is a proc called from a proc, etc.
If number is a positive value,
info level
returns a the name and arguments of the proc at that level on the
stack. Number is that same value that
info level
would return if it were called in the proc being referenced.
If number number is a negative value,
it refers to the current level plus number. Thus, info
level returns a the name and arguments of
the proc at that level on the stack.
info patchlevelReturns the value of the global variable tcl_patchlevel. This is a three-levels version number identifying the Tcl version, like: "8.4.6"
info scriptReturns the name of the file currently being evaluated, if one is being evaluated. If there is no file being evaluated, returns an empty string.
This can be used for instance to determine the directory holding other scripts or files of interest (they often live in the same directory or in a related directory), without having to hardcode the paths.
info tclversionReturns the value of the global variable tcl_version. This is the revision number of this interpreter, like: "8.4".
pidReturns the process id of the current process.