Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact

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
errors v exceptions
Solution Centre - all article listing
Solution Centre - all article listing

Articles and tips on this subjectupdated
4207Exception 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
 
366Error 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
 
3583Expanding 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
 
3570Trapping 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
 
3287Exceptions - 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
 
782Converting 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
 
2467Tcl - 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
 
239What 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
 
1338Handling 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
 
1334Stable 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
 
1277AgtInvoke - 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
 
748Getting 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
 
461Shortened interactive commands
In Tcl, if you're working in interactive mode you can abbreviate the commands you type in, as long as your commands remain unique. So instead of puts you can write put or even pu ... but if you try to run just the p command you'll get % p hello ambiguous command name "p": package pid proc puts pwd % ...
2006-06-05
(short)
Examples from our training material
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
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 http://www.training-notes.co.uk.
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,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.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/T214.html • PAGE BUILT: Thu Sep 18 11:03:17 2014 • BUILD SYSTEM: WomanWithCat