Crs 160 Programming with Tcl/TK
This course provides a comprehensive introduction to Tcl and the TK
extensions to Tcl. It is suitable both for novice and experienced programmers
who wish to use Tcl for automating repetitive tasks, application testing ,
application prototyping , rapidly developing graphical user interfaces for
non-window programs.
The course covers both console based applications that use pure tcl (and are
interpreted using tclsh) ,and applications that use the Tk windowing extensions
to tcl and are interpreted using Wish. The building blocks and syntax of tcl are
covered fully (especially substitutions and grouping).
Extensions to Tcl are discussed, and a survey of
useful extensions is provided, including Expect. The uses of Expect for
automating interactive tasks such as transferring files via FTP and sending
mail via mail are covered.
|
Course Outline
The background to Tcl/TK
- The tcl interpreters tclsh and Wish
- An overview of available Tcl libraries and their uses
- Tcl as an extensible scripting language
The basics of tcl
- commands
- variables
- scalars
- associative arrays
- substitution
- grouping
- if -- elseif -- else
- switch
- for loops and foreach loops
- while loops
- continue and break
- lists and list manipulation
- strings and string manipulation
- an introduction to regular expressions and pattern matching
- procedures and functions
- launching applications from Tcl
Tk and widgets
- what widgets are and how they work
- creating and configuring widgets
- widget hierarchies and types
- toplevel widgets
- frames
- buttons
- checkboxes and radiobuttons
- label widgets
- message and text widgets
- listboxes
- scrollbars
- canvases
- widget properties (colour, size, position)
- associating widgets, events and commands
- geometry managers
- grids
Expect
- patterns and actions
- debugging patterns and controlling I/O
- handling processes and users
- expect - internals and command line options
- send, spawn, signal and interact commands
- using expect to handle multiple concurrent processes
- running Expect in the background
|
Intended Audience
Attendees are expected to have some computer programming background, and
confidence in working in a Unix environment. Typically, the need to
know Tcl/TK will be an adjunct to some other engineering or programming
task. Most attendees attending the Tcl/TK course have a requirement
to develop test automation scripts.
|
Practical Work
The early parts of the course use simple exercises to familiarise the
attendee with the material that has been covered, and to stimulate
exploration of the possibilities of Tcl. Towards the end of the course
a number of project oriented exercises are introduced to demonstrate the
full potential of Tcl/TK.
- Developing Tcl scripts to perform system admin tasks
- Exploring the uses of Tcl for system testing purposes
by writing Tcl scripts to test out a simulated alarm system
- Implement a graphical, form based front end to an online help system
using TK
- Write an Expect program to automate downloading of files over the
internet via FTP overnight, and print out a report of successful
and unsuccessful download attempts.
- Develop a simple terminal emulator using Expect and the TK text widget
- Devise an automated mail handling and filtering facility using Expect.
|