proc f1 {} {
f2
}
proc f2 {} {
puts "The last 2 procs called is: ??????"
}
# main
f1
--------------------------
# Desired output
The last 2 procs called is: f2(), f1(), main()
Thanks,
read the man pages on the "info" command. Specifically, [info level].
You can use that command to work your way up through the call stack.
Regards
Manfred
> I need a way to find the current Proc name and also the previous Proc
> names. I need this to print out debug information.
The command you'll want to use is [info level]. See:
http://wiki.tcl.tk/1720
Try something like:
proc callstack {{level -1}} {
if {![string is integer -strict $level]} then {
return -code error "expected integer but got \"$level\""
}
if {$level > 0} then {
return -code error "expected integer <= 0 but got \"$level\""
}
set tcl_call_stack ""
set level [expr {[info level] + $level + 1}]
while {[incr level -1] > 0} {
append tcl_call_stack " called from [info level $level]" \n
}
return [string trimright $tcl_call_stack]
}
Michael
You seek the [info] command, and in particular the [info level] subcommand.
--
Darren New / San Diego, CA, USA (PST)
Scruffitarianism - Where T-shirt, jeans,
and a three-day beard are "Sunday Best."