Arjen Markus (13 february 2009) Just another page containing some tips and tricks, this one is about packages.
Whether you get a package from the teapot repository or from the distribution directly or ..., normally all you need to do is:
package require NAME
to load all parts of a package NAME and start using it.
Sometimes, however, you may want a bit of introspection:
Here are some answers:
Tcl uses the variable auto_path to look for a package. auto_path contains a list of directories to search. So if you want Tcl to look in other directories as well, simply lappend these directories to this variable.
Here is a trick Andreas Kupries came up with to find out just where the files are located:
package ifneeded NAME [package require NAME]
This command will return the exact command to get the package. It works regardless of the type of package: a Tcl-only package, a binary extension, or a Tcl module. You need to interpret the command yourself, but it contains the exact location.
(If you want to find where a particular version of the package is located, add the version information to the "package require" part)
The following command returns information about the various DLLs/shared objects you currently have loaded into the interpreter:
info loaded
The simplest way to find out what version you have loaded is to repeat the "package require" command. As it has been loaded already, nothing in particular is done, but you do get the version number.