Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

source command returns file not found. How can I specify 'search' lib

Status
Not open for further replies.

Jim78

Programmer
Mar 10, 2004
2
US
New user question. I am working with a tcl script that source'es additional scripts. However, the source command fails with 'file not found'. What environment variable, library, path, etc., do I need to configure to have this and all future 'source' commands find the additional scripts.
If I modify the script and specifically state the directory structure, the script is found, but I can't do this for each and every module.

Thanks in advance for any help you can provide.
 
You could use something like glob and specify your
source files with a special extension.
Something like:
Code:
proc findsrcfiles {dir {ext ".txt"}} {
            foreach instance [glob -nocomplain $dir/*$ext] {
                           source [file nativename $instance]
            }
}
 
Thanks marsd.
However, I'm not looking for any code, nor should I need any.
I simply need to understand how 'tcl' works.
When 'tcl' needs to 'source' some code, how does it know where to look (search) to find the new code?
There has got to be some environment variable, or something that directs this. Does anyone know?

Again, thanks in advance.
 
No, there is no variable.
You specify the sourced files directly, by path.
That is why when you said 'search' I assumed that
you had some understanding that tcl does not do any
deep magic in finding files to source. It is up
to the programmer to create a method by which
files may be sourced dynamically if that is what
you want.
See here:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top