beetlebug▾
/

info frame

Gives the count of the levels of the running code, or a dict that describes one level.

info frame ?LEVEL?

Description

A level of the running code is the run of a file, of a proc body, or of a script that a command runs, such as the script of eval or uplevel. These levels are not the levels of info level. As in Tcl, a script that if, while, for, switch, or try runs is a part of the level of its command.

With no LEVEL, gives the count of the levels. With LEVEL, gives a dict that describes that level. A LEVEL above 0 counts from the outermost level: 1 is the first. A LEVEL of 0 or less counts back from the running level: 0 is the level of the call of info frame, and -1 is the level of the command that started it. A LEVEL past either end is an error.

The dict has these keys:

The body of a proc has the type source and the lines of its file when the body is a literal word of the file. Each other proc body has the type proc, with lines from 1 in the body.

Arguments

ArgumentTypeDefaultDescription
LEVELintegernoneThe level: from the outermost level above 0, from the running level at 0 or less.

Returns

The count of the levels, or a dict of one level.

Examples

% proc f {} {dict get [info frame 0] proc}; f
::f

% proc f {} {dict get [info frame 0] type}; f
proc

% proc f {} {dict get [info frame 0] cmd}; f
info frame 0

% proc f {} {dict get [info frame -1] cmd}; proc g {} {f}; g
f

% proc f {} {dict get [info frame -1] level}; proc g {} {f}; g
1

% proc f {x} {dict get [info frame 0] line}; f 1
1

% set s {dict get [info frame 0] type}; eval $s
eval

% apply {{} {dict get [info frame 0] lambda}}
{} {dict get [info frame 0] lambda}

% oo::class create C {method m {} {info frame 0}}
> dict get [[C new] m] method
m

Errors

% info frame 99
bad level "99"
-errorcode TCL LOOKUP LEVEL 99

% info frame -99
bad level "-99"
-errorcode TCL LOOKUP LEVEL -99

% info frame a
expected integer but got "a"
-errorcode TCL VALUE NUMBER

% info frame 1 2
wrong # args: should be "info frame ?number?"
-errorcode TCL WRONGARGS

Differences from Tcl

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztcl 1.0.0-beta.5

See also