GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  INFO (n)

NAME

info - Return information about the state of the Tcl interpreter

CONTENTS

Synopsis
Description
Example
Keywords

SYNOPSIS

info option ?arg arg ...?

   








\L’|0u-1v’\l’75u+3n_’\L’0u+1v-0u’\l’|0u-1.5n_’



\L’|0u-1v’\L’0u+1v-0u’\l’|0u-1.5n_’





DESCRIPTION

This command provides information about various internals of the Tcl interpreter. The legal options (which may be abbreviated) are:
info args procname
  Returns a list containing the names of the arguments to procedure procname, in order. Procname must be the name of a Tcl command procedure.
info body procname
  Returns the body of procedure procname. Procname must be the name of a Tcl command procedure.
info cmdcount
  Returns a count of the total number of commands that have been invoked in this interpreter.
info commands ?pattern?
  If pattern is not specified, returns a list of names of all the Tcl commands visible (i.e. executable without using a qualified name) to the current namespace, including both the built-in commands written in C and the command procedures defined using the proc command. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match. pattern can be a qualified name like Foo::print*. That is, it may specify a particular namespace using a sequence of namespace names separated by double colons (::), and may have pattern matching special characters at the end to specify a set of commands in that namespace. If pattern is a qualified name, the resulting list of command names has each one qualified with the name of the specified namespace, and only the commands defined in the named namespace are returned.

   

\L’|0u-1v|’

info complete command
  Returns 1 if command is a complete Tcl command in the sense of having no unclosed quotes, braces, brackets or array element names. If the command does not appear to be complete then 0 is returned. This command is typically used in line-oriented input environments to allow users to type in commands that span multiple lines; if the command is not complete, the script can delay evaluating it until additional lines have been typed to complete the command.
info default procname arg varname
  Procname must be the name of a Tcl command procedure and arg must be the name of an argument to that procedure. If arg does not have a default value then the command returns 0. Otherwise it returns 1 and places the default value of arg into variable varname.
info exists varName
  Returns 1 if the variable named varName exists in the current context (either as a global or local variable) and has been defined by being given a value, returns 0 otherwise.
info frame ?number?
  This command provides access to all frames on the stack, even those hidden from info level. If number is not specified, this command returns a number giving the frame level of the command. This is 1 if the command is invoked at top-level. If number is specified, then the result is a dictionary containing the location information for the command at the numbered level on the stack.

If number is positive (> 0) then it selects a particular stack level (1 refers to the top-most active command, i.e., info frame itself, 2 to the command it was called from, and so on); otherwise it gives a level relative to the current command (0 refers to the current command, i.e., info frame itself, -1 to its caller, and so on).

This is similar to how info level works, except that this subcommand reports all frames, like sourced scripts, evals, uplevels, etc.

Note that for nested commands, like “foo [bar [x]]”, only “x” will be seen by an info frame invoked within “x”. This is the same as for info level and error stack traces.

The result dictionary may contain the keys listed below, with the specified meanings for their values:
type This entry is always present and describes the nature of the location for the command. The recognized values are source, proc, eval, and precompiled.
source        
  means that the command is found in a script loaded by the source command.
proc        
  means that the command is found in dynamically created procedure body.
eval        
  means that the command is executed by eval or uplevel.
precompiled        
  means that the command is found in a precompiled script (loadable by the package tbcload), and no further information will be available.
line This entry provides the number of the line the command is at inside of the script it is a part of. This information is not present for type precompiled. For type source this information is counted relative to the beginning of the file, whereas for the last two types the line is counted relative to the start of the script.
file This entry is present only for type source. It provides the normalized path of the file the command is in.
cmd This entry provides the string representation of the command. This is usually the unsubstituted form, however for commands which are a pure list executed by eval it is the substituted form as they have no other string representation. Care is taken that the pure-List property of the latter is not spoiled.
proc This entry is present only if the command is found in the body of a regular Tcl procedure. It then provides the name of that procedure.
lambda This entry is present only if the command is found in the body of an anonymous Tcl procedure, i.e. a lambda. It then provides the entire definition of the lambda in question.
level This entry is present only if the queried frame has a corresponding frame returned by info level. It provides the index of this frame, relative to the current level (0 and negative numbers).
A thing of note is that for procedures statically defined in files the locations of commands in their bodies will be reported with type source and absolute line numbers, and not as type proc. The same is true for procedures nested in statically defined procedures, and literal eval scripts in files or statically defined procedures.

In contrast, a procedure definition or eval within a dynamically evaluated environment count linenumbers relative to the start of their script, even if they would be able to count relative to the start of the outer dynamic script. That type of number usually makes more sense.

A different way of describing this behaviour is that file based locations are tracked as deeply as possible, and where this is not possible the lines are counted based on the smallest possible eval or procedure body, as that scope is usually easier to find than any dynamic outer scope.

The syntactic form {*} is handled like eval. I.e. if it is given a literal list argument the system tracks the linenumber within the list words as well, and otherwise all linenumbers are counted relative to the start of each word (smallest scope)

info functions ?pattern?
  If pattern is not specified, returns a list of all the math functions currently defined. If pattern is specified, only those functions whose name matches pattern are returned. Matching is determined using the same rules as for string match.
info globals ?pattern?
  If pattern is not specified, returns a list of all the names of currently-defined global variables. Global variables are variables in the global namespace. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match.
info hostname
  Returns the name of the computer on which this invocation is being executed. Note that this name is not guaranteed to be the fully qualified domain name of the host. Where machines have several different names (as is common on systems with both TCP/IP (DNS) and NetBIOS-based networking installed,) it is the name that is suitable for TCP/IP networking that is returned.
info level ?number?
  If number is not specified, this command returns a number giving the stack level of the invoking procedure, or 0 if the command is invoked at top-level. If number is specified, then the result is a list consisting of the name and arguments for the procedure call at level number on the stack. If number is positive then it selects a particular stack level (1 refers to the top-most active procedure, 2 to the procedure it called, and so on); otherwise it gives a level relative to the current level (0 refers to the current procedure, -1 to its caller, and so on). See the uplevel command for more information on what stack levels mean.
info library
  Returns the name of the library directory in which standard Tcl scripts are stored. This is actually the value of the tcl_library variable and may be changed by setting tcl_library. See the tclvars manual entry for more information.
info loaded ?interp?
  Returns a list describing all of the packages that have been loaded into interp with the load command. Each list element is a sub-list with two elements consisting of the name of the file from which the package was loaded and the name of the package. For statically-loaded packages the file name will be an empty string. If interp is omitted then information is returned for all packages loaded in any interpreter in the process. To get a list of just the packages in the current interpreter, specify an empty string for the interp argument.
info locals ?pattern?
  If pattern is not specified, returns a list of all the names of currently-defined local variables, including arguments to the current procedure, if any. Variables defined with the global, upvar and variable commands will not be returned. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match.
info nameofexecutable
  Returns the full path name of the binary file from which the application was invoked. If Tcl was unable to identify the file, then an empty string is returned.
info patchlevel
  Returns the value of the global variable tcl_patchLevel; see the tclvars manual entry for more information.
info procs ?pattern?
  If pattern is not specified, returns a list of all the names of Tcl command procedures in the current namespace. If pattern is specified, only those procedure names in the current namespace matching pattern are returned. Matching is determined using the same rules as for string match. If pattern contains any namespace separators, they are used to select a namespace relative to the current namespace (or relative to the global namespace if pattern starts with ::) to match within; the matching pattern is taken to be the part after the last namespace separator.
info script ?filename?
  If a Tcl script file is currently being evaluated (i.e. there is a call to Tcl_EvalFile active or there is an active invocation of the source command), then this command returns the name of the innermost file being processed. If filename is specified, then the return value of this command will be modified for the duration of the active invocation to return that name. This is useful in virtual file system applications. Otherwise the command returns an empty string.
info sharedlibextension
  Returns the extension used on this platform for the names of files containing shared libraries (for example, .so under Solaris). If shared libraries are not supported on this platform then an empty string is returned.
info tclversion
  Returns the value of the global variable tcl_version; see the tclvars manual entry for more information.
info vars ?pattern?
  If pattern is not specified, returns a list of all the names of currently-visible variables. This includes locals and currently-visible globals. If pattern is specified, only those names matching pattern are returned. Matching is determined using the same rules as for string match. pattern can be a qualified name like Foo::option*. That is, it may specify a particular namespace using a sequence of namespace names separated by double colons (::), and may have pattern matching special characters at the end to specify a set of variables in that namespace. If pattern is a qualified name, the resulting list of variable names has each matching namespace variable qualified with the name of its namespace. Note that a currently-visible variable may not yet “exist” if it has not been set (e.g. a variable declared but not set by variable).

EXAMPLE

This command prints out a procedure suitable for saving in a Tcl script:


proc printProc {procName} {
    set result [list proc $procName]
    set formals {}
    foreach var [info args $procName] {
        if {[info default $procName $var def]} {
            lappend formals [list $var $def]
        } else {
            # Still need the list-quoting because variable
            # names may properly contain spaces.
            lappend formals [list $var]
        }
    }
    puts [lappend result $formals [info body $procName]]
}


SEE ALSO

global(n), proc(n)

KEYWORDS

command, information, interpreter, level, namespace, procedure, variable
Search for    or go to Top of page |  Section n |  Main Index


Tcl INFO (n) 8.4

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.