Skip to content

Instantly share code, notes, and snippets.

@brabect1
Created August 20, 2019 17:22
Show Gist options
  • Save brabect1/19a3229b3cae74858612636f36a8c1e5 to your computer and use it in GitHub Desktop.
Save brabect1/19a3229b3cae74858612636f36a8c1e5 to your computer and use it in GitHub Desktop.
#tcl #modules #packages

Modules in Tcl

There are more ways ...

Tcl Modules

Directory structure:

<path>
  +- foo.tcl
  +- [mods]
        +- bar-1.0.tm

Use:

$bash> export TCL8_6_TM_PATH=${pwd)/mods
$bash> tclsh foo.tcl
Foo started ...
Bar Me...
Foo completed, cao!

Here is how the .tm module may look like:

namespace eval ::bar {
}

proc ::bar::barMe {} {
    puts "Bar Me...";
}

And the Tcl script:

package require bar;

puts "Foo started ...";
::bar::barMe;
puts "Foo completed, cao!";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment