For 2023 - we are now fully retired from IT training. We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.
Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!
I am also active in many other area and still look after a lot of web sites - you can find an index ((here)) |

Well House Consultants
You are on the site of
Well House Consultants
who provide
Open Source Training Courses
and business
hotel accommodation. You are welcome to browse and use
our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
|
Tcl/Tk module T214
Other Facilities in Tcl
Exercises, examples and other material relating to training module T214. This topic is presented on public courses Learning to program in Tcl, Tcl Programming, Tcl Programming
A miscellany of commands, including more on error and file handling, and information commands. Related technical and longer articles Solution Centre - all article listingSolution Centre - all article listingerrors v exceptions
Articles and tips on this subject | updated | 4762 | Coverage map in Tcl - how many times has each proc been called? Just finished a lovely course in Dublin ... Tcl Programming - or rather a tailored version of it.
One of the requirements for this customer is a coverage map - in other words, he requires the ability to run his code and find which procs have been used and how many times.
Method - rename the existing ... | 2017-09-28 (short) | 4525 | What does Tcl do if you try to run a command that is not defined? In Tcl, if a command doesn't exist within the loaded code the interpretter will look through the commands that can be loaded vis package ifneeded, and failing that will call the unknown proc. And there's nothing to stop you defining unknown for yourself, as I did as a demonstration on Friday afternoon ... | 2015-10-10 | 4523 | Catching failed commands and not crashing the program in Tcl Where a command may fail in Tcl (causing Tcl to crash), you can defer it within a catch command. That will return a true value if it fails, and an optional extra parameter gives you the associated error message.
A program to look for the biggest file in or below a directory [here] fails if you run ... | 2015-10-10 | 4207 | Exception handling in Tcl Exceptions are a wonderful fail safe way of trapping errors in most modern programming languages. Although the natural way for a newcomer to programming to handle unusual situations is to test for each possible situation, that becomes a guessing game trying to work out everything that may happen, and ... | 2013-11-16 | 366 | Error handling in Tcl through catch Tcl is a truly interpretive language - and that means that you can get a syntax error if a user makes an illegal entry ... even in the middle of a program running. For example
puts -nonewline "please enter a number: "
flush stdout
gets stdin value
set doubled [expr $value * 2]
puts "Result is $doubled"
puts ... | 2012-03-04 | 3583 | Expanding a list of parameters in Tcl - {*} and eval In Tcl commands, parameters are separated by spaces, just like Tcl lists are. So it would sometimes be very useful to be able to write
set action {piemiddle apple}
set $action
to take a list of parameters from a Tcl list - in this case setting the "piemiddle" variable to the ... | 2012-01-28 | 3570 | Trapping errors in Tcl - the safety net that catch provides What could possibly go wrong when you open a file in a program? Lots of things, actually.
* You could try to open a file in directory you cannot access
* You could try to read from a file that does not exist
* You could try to read from something that's not a plain file - e.g. a directory
* You could ... | 2012-01-07 | 3287 | Exceptions - Tcl style Checking for all possible errors isn't a "failsafe" way of coding. If you try and check for absolutely any error, you're still very likely to miss one or two possibilities, and it's fare better to add a block to your code to say (in essence) "if anything at all goes wrong, go here...". And that's ... | 2011-05-12 | 782 | Converting between Hex and Decimal in Tcl Tcl is much used in the semiconductor industry, so there's a common requirement to use it to convert values back and forth between hexadecimal (base 16) and decimal (base 10).
Easily done! The format command can be used to convert from decimal to hexadecimal, and the expr command can be used to convert ... | 2011-03-01 | 2467 | Tcl - catching an error before your program crashes There are times when a Tcl command can fail because of the data being passed in to it ... and when it fails, it can do so with a spectacular crash! For example, the glob command which matches files to a pattern (Tcl's ls or dir if you like to think of it that way) can go 'belly up' if there are no files ... | 2009-10-22 | 239 | What and why for the epoch The Epoch occurred on 1st January 1970 ... at midnight, at the start of the day, GMT. It's an important concept in many programming languages, which work with times and dates before and after the epoch - it means that you can compare dates and times easily, even where month ends and different timezones ... | 2008-05-16 | 1338 | Handling Binary data in Tcl (with a note on C) In Tcl, all variables are held as strings, and most of the commands will split / divide strings at new line or space characters by default. However, there are a few commands that do NOT make that distinction and since a Tcl string (Unlike a C string) may contain any bit pattern at all, they provide a ... | 2007-09-11 | 1334 | Stable sorting - Tcl, Perl and others Have you come across a STABLE sort? A Stable sort is one in which all the incoming elements which evaluate to an equal value when tested for sorting purposes remain in the same order in the output as they were in the input. Perhaps I had better give you an example.
I have a log file and there's a ... | 2007-09-07 | 1277 | AgtInvoke - a command to drive Agilent Tcl software extensions In Tcl, there's a lot of commands available already - and there would be a lot more if separate commands were provided for each operation you might wish to perform. So some of the commands that are provided are really megacommands that wrap a whole lot of others up in a single group.
Let's take string ... | 2007-07-25 | 748 | Getting rid of variables after you have finished with them If you've finished with a variable in your program, you can usually just leave it "in situe" and it will be destroyed and the memory it occupied will be released when you exit from your program. In many languages, variables within named blocks of code have an even shorter "shelf life" - by default, a ... | 2006-06-09 | 364 | pu daily and p hourly Tcl is a command based language - everything you do uses a command that starts with a command word such as puts to output information or set to assign a value to a variable. The while command (yes, it really is a command) lets you define a block of code that's to be run repeatedly while a condition ... | 2006-06-05 |
Examples from our training material
dunno | unknown command calls unknown proc | edo | Running an external process in Tcl | err1 | Example of a Tcl program that fails | err2 | A Tcl program that uses catch to trap a run time error | firstline | Using catch to trap runtime errors | fishing | exceptions in Tcl | goalie | catching exceptions - Tcl style | lick | Finding size of .gif image in Tcl - binary scan | netting | catch - catching error, and error message too | times | proc coverage example | vt | Tcl program that manipulates a variable | vtt | Tcl program that uses the trace command to report the manipulation of a variable |
Pictures Tcl trainees on a practical
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 [here].
Topics covered in this module
Information. The info command. Other information commands. history. Error control. unknown. File handling. fconfigure. seek. Variable control. unset. Tracing a variable in Tcl. Special variables. Other Subjects for group discussion.
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, Ruby,
Lua,
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.
|
|
|