Is there a way in TCL to know (at runtime):
1. Name/Path of all files sourced using source command
2. Name/Path of the file containing a a proc, for e.g., foo, assuming
that the file is sourced in the interpreter and the function
definition is availble.
3. Name/Path of the file containing a a proc, for e.g., foo, assuming
that the file is sourced in the interpreter and the function
definition is availble and the function is invoked. In other words, if
I want to display the path/name of the file and function name upon
invocation.
Any info. will be of great help.
Regard
Sharad
info script tells you the info for the running script, and info commands
and friends lets you see what is there so you can note stuff before and
after load.
Michael
I thought of this earlier and just tried it out. This will definitely
work but to me it does not look a very neat approach and is more of a
workaround than a solution. I am trying to evaluate other options, if
there are any, and then implement.
If I do not find anything better, I've no other option than to use
it :-)
Thanks much for the prompt response.
Regards
Sharad
In 8.5 you may find that [info frame] is of some interest. Details may
be read at http://www.tcl.tk/man/tcl8.5/TclCmd/info.htm#M12
Donal.
How come file is only available for the source type (I'd think it would also
make sense for the precompiled type)?
--
+--------------------------------+---------------------------------------+
| Gerald W. Lester |
|"The man who fights for his ideals is the man who is alive." - Cervantes|
+------------------------------------------------------------------------+
And how comes, that the file is only available while sourcing and not
even afterwards in the scope of a previously source'ed procedure?
Best regards,
Martin
On Aug 9, 3:08 pm, "Gerald W. Lester" <Gerald.Les...@cox.net> wrote:
> Donal K. Fellows wrote:
> > Sharad wrote:
> >> 3. Name/Path of the file containing a a proc, for e.g., foo, assuming
> >> that the file is sourced in the interpreter and the function
> >> definition is availble and the function is invoked. In other words, if
> >> I want to display the path/name of the file and function name upon
> >> invocation.
>
> > In 8.5 you may find that [info frame] is of some interest. Details may
> > be read athttp://www.tcl.tk/man/tcl8.5/TclCmd/info.htm#M12
I suspect it is because if someone is using the precompiled type, they
want to obscure details. Ask the ActiveState-ers if you want a more
definitive answer.
Donal.
The filename is available for things defined within the context of a
sourced file. But (for reasons that defeat me right now) only when the
frame in question is on the stack. It might be possible in the future to
expose that info in other ways too (e.g. an [info source $proc] or
something like that[*].)
Donal.
[* Not a serious suggestion! Just riffing on the idea. ]
I like it, I like it!