How can be find the location of procedure (function) in TCL. Under location I mean the source file in which it is declared.
I'm trying to read foreign source-code and can not find the declaration of a single procedure, example:
set MSISDNElement [regexp -all -inline {ISDN +[0-9]+} $Command]
if { $MSISDNElement != "" } {
foreach elm $MSISDNElement {
set MSISDNValue [list ISDN [getInternationalFormat [lindex $elm 1]]]
}
}
set EptData [list [lindex $Command 1]]
InitEptData 3
foreach Element $EptData {
SetEptData [lindex $Element 0] [lindex $Element 1]
}
For the functions InitEptData & SetEptData I can't find any declaration. Could someone familiar much more in deep with TCL, to explain how to solve that issue which I'm facing? Thanks in advance!
There is no generic answer to this, as Tcl allows you to declare procedures on the fly, so they could have no actual file reference.
There are some attempts to improve the situation for procs that have a defining file, for example TIP280, which is actually available as info frame
in recent 8.5 versions, and TIP 86, which is only in discussion.
But if a simple grep
does not work, you could track the moment a procedure or command gets created.
This happens in various places (Tcl OO might add a few more, not sure):
load
command when a binary extension registers its command handler functions with Tcl_CreateCommand or the more modern Tcl_CreateObjCommand.source
command when a file with proc definitions is loadedproc
command itself to define a new procedureUsing the commands info commands
and namespace children
you can walk the whole namespace tree to get a list of defined commands before and after the executed command. So you can create a wrapper that tracks any new commands. See http://wiki.tcl.tk/1489 for some hints how to do it.
Or, simply use a debugger like RamDebugger http://www.compassis.com/ramdebugger/Intro, or ActiveStates commercial debugger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With