I have a question about package in TCL
I have a test1.tcl file:
package provide hello 0.1.0
set globalVariable 20
this file in required in test2.tcl
package require hello 0.1.0
puts $globalVariable
and the pkgIndex.tcl is:
package ifneeded hello 0.1.0 [list source [file join $dir test1.tcl]]
when I execute the test2.tcl, it tells me, the package hello 0.1.0 is not found.
I try to execute the pkgIndex.tcl, it tells me can not read variable dir, all of these three files are under the same folder. how could I fix it? can anyone help?
You need to read the documentation for
pkg_mkIndexwhich explains how the interpreter goes about looking for packages to load. The short version is: