Re: how to universally source files



On Mon, 27 Nov 2006, Darren New wrote:

comp.lang.tcl wrote:
It's the latter but I'll remember the property trick, thanx!

The basic problem is that you're using relative file names, and in one
case your current working directory is correct and in the other case it
isn't correct.

That's what you need to fix, by either using full path names or by
cd'ing to the right directory first.

Here is a little helper function I often use (especially when I intend to
eventually package things up as a starkit--this code would then go in
myapp.vfs/main.tcl):

proc ~/ {} [list return [file normalize [file dirname [file join \
[pwd] [info script]]]]]

Then later I can use it like so:

source [file join [~/] src gui.tcl]
source [file join [~/] src database.tcl]

etc.

Works whether I run it from Unix (or Windows), wrapped as a starkit (in
which case the src/ directory is in the vfs of the .kit), or fire up tclsh
or wish and manually source in my main.tcl.

Michael
.