Wrapping Libraries of Tcl Scripts
You must take special steps to auto-load Tcl script libraries that you wrap with your application. For example, if a library consists of the files help.tcl and display.tcl, and they and the tclIndex file are stored in /usr/local/lib/common, an unwrapped Tcl script that used this library would contain the following command to auto-load the library:
lappend auto_path /usr/local/lib/common
This command would fail to auto-load your library in a wrapped application because of the absolute pathname. You can correct this problem in one of two ways:
- Change your application to test if it is executing as a wrapped application, and then set the auto_path variable appropriately:
if {[info exists tcl_platform(isWrapped)]} {
lappend auto_path lib/common
} else {
lappend auto_path /usr/local/lib/common
}
- Then wrap your application as follows (remember to wrap the tclIndex file in addition to the Tcl script files):
% prowrap myscript.tcl -relativeto /usr/local \
/usr/local/lib/common/*.tcl /usr/local/lib/common/tclIndex
- Set the auto_path variable using the code option of the prowrap command. The code option executes the Tcl code that you provide before executing the Tcl scripts of your application. Thus, the following prowrap command accomplishes the same results as above (remember to wrap the tclIndex file in addition to the Tcl script files):
% prowrap myscript.tcl -relativeto /usr/local \
/usr/local/lib/common/*.tcl /usr/local/lib/common/tclIndex \
-code "lappend auto_path lib/common"
http://www.ajubasolutions.com Voice: (650) 210-0100 Fax: (650) 210-0101 support@ajubasolutions.com |