我需要在它的正文中获取tcl proc的调用行号.
从8.5 tcl开始有info frame命令允许以下内容:
proc printLine {} {
set lineNum [dict get [info frame 1] line]
}
Run Code Online (Sandbox Code Playgroud)
我需要相同的8.4
它在8.4中不可用; 根本没有收集数据.我想你可以在线上搜索一个唯一的令牌,但那就是全部.
proc lineNumber {uniqueToken} {
set name [lindex [info level 1] 0]
set body [uplevel 2 [list info body $name]]
set num 0
foreach line [split $body \n] {
incr num
if {[string first $uniqueToken $line] >= 0} {
return $num
}
}
error "could not find token '$uniqueToken'"
}
Run Code Online (Sandbox Code Playgroud)
请注意,不再支持8.4.升级.