info vars
Gives the names of the variables that the current scope can read.
info vars ?PATTERN?
Description
In a proc, gives each local variable and each variable that global, upvar, or variable links into the proc. At the global scope, gives the global variables. In namespace eval, gives the variables of the namespace and the global variables.
With PATTERN, the list has only the names that match it as a glob pattern. A PATTERN with ::, such as ::ns::*, lists the variables of that namespace with their full names.
Arguments
| Argument | Type | Default | Description |
|---|---|---|---|
| PATTERN | glob pattern | none | The names to keep. |
Returns
A list of variable names.
Examples
% proc f {} {global gv; set gv 1; set loc 2; lsort [info vars]}
> f
gv loc
% set v 1; info vars v
v
% namespace eval ns {variable q 1}; info vars ::ns::*
::ns::q
Errors
% info vars a b
wrong # args: should be "info vars ?pattern?"
-errorcode TCL WRONGARGS
Facts
- Capability
- None.
- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.1