Exercises, examples and other material relating to training module T245. This topic is presented on public courses Learning to program in Tcl
, Tcl Programming
, Tcl Programming
[incr-Tcl] is the Object Oriented extension to Tcl which is now available Open Source like the main language. This module looks at class and object definition and use, and how Tcl implements inheritance and overloading.
Related technical and longer articlesIncr-Tcl - Object Oriented extension to TclLoading incr-tcl into tclshindex
|Articles and tips on this subject||updated|
|4460||Using Object Oriented Tcl and the Tk toolkit together - real life example|
There are all sorts of ways to look at the survey data we gathered last October on the TransWilts trains, and one fact I'm particularly interested in is the journey lengths of passengers. I have all the information to hand that I need to work this out - but in different files:
Survey data [here]
|4456||Objects in Tcl - iTcl - updated first steps example|
iTcl is Tcl's Object Oriented package, and it's shipped as standard with Tcl these days.
On many of our OO courses, we start off with an example of "train" objects and define and run methods such as "getCapacity" on them, and today I've taken that same example and coded it in Tcl - see [here].
|3142||Private and Public - and things between|
A public train service is one which is available for anyone to travel on; a private one only takes limited passengers as invites / made available by the operator. And there could be intermediate levels too - I understand that at times the British Transport Police protect the last train from Weymouth ...
|1925||Introduction to Object Oriented Programming|
"Object Oriented Programming" is a whole new philosophy for programmers who have been writing short scripts for years, and it can be quite frightening to learn with all these new buzzwords like "overriding", "encapsulation" and "polymorphism" creeping in. It's a beautiful concept and a lovely approach, ...
|1819||Calling base class constructors|
In all object oriented languages, you have a facility called inheritance where you can define one type of thing ("class of object") based on another, and the newly defined class ("subclass" or "extended class") takes the initial ("base") class as it starting point.
In your code for your base class, ...
|1528||Object Oriented Tcl|
Object Oriented Tcl ([incr-Tcl]) is darned good - but it's only a requirement in a small proportion of the Tcl Training Courses that I give. So it was with real pleasure that I spent some time yesterday writing an example in front of my class in the Nottingham area to show them just how fabulous it ...
|290||Object Orientation in Tcl - [incr-Tcl]|
For medium sized to huge projects, an Object Oriented approach to programming can pay massive dividends at (perhaps) the initial cost of a longer design phase and class testing.
Tcl is the oldest of the Open Source languages that we offer courses on, and it's a command based language that was written ...
Examples from our training material
|animal.itcl|| A simple class in [incr-tcl] |
|animal2.itcl|| class that loads Itcl into basic Tclsh|
|bigger.itcl|| [Incr-Tcl] Demonstration 2|
|exv|| Multiple classes and inheritance demonstration|
|film.itcl|| [incr-Tcl] - Base class and two classes that inherit from it |
|find.itcl|| List available classes in [Incr-Tcl]|
|hello.itcl|| [Incr-Tcl] Demonstration|
|inherits.itcl|| Multiple inheritance and constructor calls|
|itlist|| Using [incr-Tcl] to hold a list of objects|
|ootcl01|| Creating and using objects|
|ootcl02|| Creating and using objects, cget and configure|
|pet.itcl|| itcl - second sample class|
|petal|| Example that loads Itcl into tclsh|
|weekend.itcl|| [incr-Tcl] - Inheritance and Polmorphism - main file|
Some modules are available for download
as a sample of our material or under an Open Training Notes License
for free download from [here]
Topics covered in this module
Hello Object World.
The class used.
Other facilities in simple objects.
Inheritance in [incr-Tcl].
Other commands available in [incr-Tcl].
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule
Well House Consultants specialise in training courses in
. We run
throughout the UK (and beyond for longer courses), and
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.