Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
TCL question - accessing same-directory files

Posted by dvorak_user (dvorak_user), 8 February 2008
Once again, I barely managed to fit in that topic title!

For a while, I've tried to figure out how to access files in the same directory (in the context of multi-file programs), but I always get a "file does not exist" error unless the working directory is the same as the one that contains the files. Mainly, I would like to know how a script can either run scripts in its directory or obtain its absolute location.

Thanks for your time! This should be an easy one to figure out, but I just haven't had any luck.

Posted by admin (Graham Ellis), 8 February 2008
Add a "." to the appropriate path variable.   Tcl has a number of predefined variable s and if you lappend a "." for current directory before you read the file ...

Code:
% puts $tcl_libPath
/usr/lib/tcl8.4 /lib/tcl8.4 /usr/library /library /tcl8.4.7/library /System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts
% puts $auto_path
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts /System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources /usr/lib ~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks
% put $tcl_pkgPath
/System/Library/Frameworks/Tcl.framework/Versions/8.4/Resources/Scripts ~/Library/Tcl /Library/Tcl /Network/Library/Tcl /System/Library/Tcl ~/Library/Frameworks /Library/Frameworks /Network/Library/Frameworks /System/Library/Frameworks
%




This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho