Well, there's a few possibilities, depending on where the file is that you're interested in.
Is the file that you're opening in the collection of scripts that you're wrapping? In that case, go to the
TclPro User's Guide and carefully read the section "How the Internal File Archive Works in a Wrapped Application." As described there, "If you attempt to access a file using a relative pathname (for example,
images/widget2.gif), then your Tcl script first looks for the file in the internal file archive. If it finds a file in the archive with the exact relative pathname specified, then it uses that file; otherwise, it looks for the file on your disk." So, if you had the following file structure for your unwrapped application:
Code:
main.tcl
lib/help.tcl
images/icon.gif
you should be able to do [tt]open images/icon.gif r[/tt] from your
main.tcl script with no problem, either unwrapped or wrapped.
Now, if the file you're interested in isn't in the archive, then I'm assuming that you're looking for a file relative to the location of your wrapped application. (If not, then you need to have the user provide an absolute path name. Which is only reasonable. I wouldn't expect to be able to type in the name of a file and have an application magically find it whatever directory it might be in, unless the application were a file finder.) There are a couple of Tcl commands that might help you here:
info script and
info nameofexecutable.
info script returns the path name of the currently executing script. The only problem is, I don't remember how it responds if the script in question is in a wrapped application. In contrast,
info nameofexecutable returns the full path name of the binary file from which the application was invoked. I've not tried it out with a wrapped application, but I suspect that this command would return the path of your wrapped application. Given this information, you could then use path manipulation commands like
file join and
file dirname to build the path to the file you want to open. - Ken Jones, President, ken@avia-training.com
Avia Training and Consulting,
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax