Exercises, examples and other material relating to training module T213. This topic is presented on public courses
Learning to program in Tcl,
Tcl Basics
Tcl Programming - The Tcl programming language, and Expect
This course covers the fundamentals of the Tcl
programming language. You'll learn about Tcl ... http://www.wellho.net/course/tbfull.html [course] |
Learning to Program in Tcl - The Tcl programming language, and Expect
This course covers the fundamentals of the Tcl
programming language. You'll learn ... http://www.wellho.net/course/tlfull.html [course] |
Packages in Tcl allow you to define a file of code that's going to be loaded as required at run time. Namespaces allow you to define a new set of variable ... http://www.wellho.net/mouth/146_exam ... kages.html [short article] |
Tcl procs (they're Tcl's functions) can pass information back via the return command, and they can access data in the top level of code via the global ... http://www.wellho.net/mouth/2476_Tcl ... level.html [short article] |
Tcl supports both packages (which allow code to be loaded from libraries at run time) and namespaces (which allow for procs and variables to be grouped ... http://www.wellho.net/mouth/1529_Tcl ... ether.html [short article] |
Are Suitcases and Aircraft the same things? No, clearly they're not, but you'll often use them in close assocoation with one another. When I was in ... http://www.wellho.net/mouth/1339_Pac ... craft.html [short article] |
#!/usr/bin/tcl
# Count calls to a proc, use namespaces
namespace eval fingers {
variable currentcount 0
namespace export counter
proc ... http://www.wellho.net/resources/ex.php4?item=t213/ns_exim [code sample] |
As your code grows, you'll want to divide it into series of modules. These are known as packages in Tcl. You'll also want to use a separate namespace so that procedure names in one package don't conflict with the same procedure name in another. Libraries allow you to load code in C as well as Tcl into your interpreter.
This topic is presented on public courses
Learning to program in Tcl,
Tcl Basics
Examples from our training material
| 2wice | Using a package that contains a namespace |
| dinpack | Using packages and namespaces together |
| doubler.tcl | define a package to contain a namespace |
| gpack.tcl | package goose - goes with dinpack |
| ns_exim | Namespace export and import |
| ns_no | shows how variables are lost between proc calls |
| ns_up | Variables saved between proc calls in the next code level up |
| ns_y2 | Counting proc calls using a namespace - shorter example |
| ns_yes | Saving variables in a namespace |
| packs | Loading a package |
| show.tcl | Defining a package |
| toes.tcl | Package to go with twice demo |
| tpack.tcl | package chicken - part of dinpack demo |
| twice | Using a package - without namespaces |
| updown | uplevel - performed in calling code variable space |
Pictures
Public Tcl course
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
Startup files.
Libraries and packages.
Locating and loading packages.
Using variables across procs and packages.
Namespaces.
Exporting and importing.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Tcl/Tk, Expect,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.