[ACCEPTED]-a question about source in Tcl-tcl
To source a file that is in the same directory 10 as the currently executing script, use this:
source [file join [file dirname [info script]] "test7.tcl"]
Note 9 that this doesn't work inside procedures defined 8 inside the outer script (test8.tcl in your 7 case) because they're typically called after 6 the source finishes. If that's the case 5 for you, the simplest fix is to just save 4 the output of
info script in a variable in your outer 3 script (or just source all files immediately 2 instead of lazily for the ultimately best 1 approach).
source [file join [file dirname [info script]] test7.tcl] -- that way you'll be sourcing the 4 target file by its full pathname constructed 3 from the full pathname of the file executing 2
source; this will work no matter what your current 1 directory is during the execution.
You don't have to specify the path of the 3 file to be sourced relative to the path 2 of
test8.tcl but relative to the current working directory. E.g. use the absolute 1 path:
More Related questions