proc one {} {
two
}
proc two {} {
# Would say 'I was called from 'one'!'
}
Or something like that.
Thanks in advance, answers would be appreciated be email,
gta...@ednet.co.uk
Cheers
Garry
see the man page on info for details but
puts "I was called from '[lindex [info level -1] 0]' - but first call was to '[lindex [info level 1] 0]'"
should do the trick (negative work up the stack, positive down)
# quick tester:
proc who_called {} {
puts "I was called from '[lindex [info level -1] 0]' - but first call was to '[lindex [info level 1] 0]'"
}
proc a {} {who_called}
proc b {} {who_called}
proc c {} {who_called}
proc d {} {a}
proc e {n} {$n}
# end
Output:
% a
I was called from 'a' - but first call was to 'a'
% b
I was called from 'b' - but first call was to 'b'
% c
I was called from 'c' - but first call was to 'c'
% d
I was called from 'a' - but first call was to 'd'
% e a
I was called from 'a' - but first call was to 'e'
% e b
I was called from 'b' - but first call was to 'e'
% e c
I was called from 'c' - but first call was to 'e'
% e d
I was called from 'a' - but first call was to 'e'
Bruce
Here is the backtrace proc:
proc getBackTrace { backTraceRef } {
upvar $backTraceRef backTrace
set startLevel [expr {[info level] - 2}]
for {set level 1} {$level <= $startLevel} {incr level} {
append backTrace "[lindex [info level $level] 0] => "
}
}
==> Will Taylor
Gaz Taylor wrote:
--
Will Taylor > Computational Sciences Division, Code IC
NASA Ames Research Center - voice:(650)604-3364, fax:(650)604-3594
Bldg 269, room 276, MS 269-2, Moffett Field, CA 94035-1000
tay...@ptolemy.arc.nasa.gov
http://ic-www.arc.nasa.gov/ic/people/taylor/taylor-home.html