Objects in TCL

When it became apparent that I had a lot of extensions to add to the original TCL language I realised that extending the language in its old form was likely to be problematical as each extension was likely to add new reserved words, and these were likely to conflict with existing scripts. Also the namespace would become busy. So instead I elected to extend the language in the form of the more modern Object-Oriented approach.

An object is a functional grouping, bringing together data, access methods (like subroutines or functions) and function. The declaration section of a script creates whole objects, each of which can have many instance variables (their data) and methods. Only those objects used in a script are created, so the names of instance variables and methods of unused object types are not reserved in the language.

The following object types are defined presently, but new ones are constantly being added!

Qtu

Qtus are not true objects (yet) - they have no methods, but some are planned to allow a TCL script to communicate with a Q-script running on the QTU.

QtuThrottle

QtuThrottles are not true objects, but embed data and function. Four QtuThrottles are contained in each Qtu.

DccCab

DccCabs are the link between a TCL script and a DCC command station. Using an NCE command station Tcc can drive DCC trains and control lights and sound through functions F0 to F28.

System

Only a single System object exists and it doesn't need to be declared. The system object handles system-wide functions such as window positions and command entry.

String

A string variable can hold, as its name suggests, a text string. All other data variables hold only numbers. String variables have methods that allow extensive manipulation of the strings.

Train

A train variable acts as an overseer to the handling of a train. It keeps track of which QTU is feeding power to its loco, keeps calibration for the loco and translates QTU integral data into exact train position along each track.

Priority

A priority variable is useful for resolving priority decisions. Several choices and their priorities are given to the variable and the highest priority is indicated. The same decisions can be made using basic TCL, but it can get rather messy.

Database Query

A query variable allows TCL to create, update and query an SQL database. The results of the most recent query (which can be a whole array of data) is cached in the query variable and can easily be used within the TCL script.

CtcText

A CtcText object hold several lines of text for display on a CTC window. It displays the text in priority order and can remove lines either after a given time, or when the script says to delete them.

Tag reader

A Tag Reader object acts as the script interface to an RFid reader. It keeps track of which tags have been read and queries the database for rolling stock data.

CTC

A CTC object provides a wide range of methods to display text, images, sprites and track on its CTC window, as well as being able to pan, size and manipulate the window.

Last Updated 9 August 2011

©Howard Amos 2009-2011