Version 0 of Tcl Module basic template

Updated 2010-02-07 07:05:29 by JMN

Sometimes it's convenient to use an existing Tcl module file as a starting point for a new one, or to quickly change a version number for testing.

Below is a basic template for a Tcl .tm file which allows you to change the package name and associated namespace, as well as the version number, simply by renaming the .tm file itself.


  namespace eval pkgtemp {
      set modver [file root [file tail [info script]]]
      lassign [split $modver -] ::pkgtemp::ns ::pkgtemp::version
  }
  package provide $::pkgtemp::ns [namespace eval $::pkgtemp::ns {
      variable version $::pkgtemp::version
      set version
  }]
  namespace eval $::pkgtemp::ns {
      #module code  here
  }
  namespace delete pkgtemp

See also