Exercises, examples and other material relating to training module T207. This topic is presented on public courses
Learning to program in Tcl,
Tcl Basics
Tcl Programming - The Tcl programming language, and Expect
This course covers the fundamentals of the Tcl
programming language. You'll learn about Tcl ... http://www.wellho.net/course/tbfull.html [course] |
Learning to Program in Tcl - The Tcl programming language, and Expect
This course covers the fundamentals of the Tcl
programming language. You'll learn ... http://www.wellho.net/course/tlfull.html [course] |
All the programming languages that we train on provide the facility for you to write a named block of code and the call it from elsewhere - such blocks ... http://www.wellho.net/mouth/308_Call ... value.html [short article] |
In Tcl, variables are "scoped" to the procedure in which they're used. That's a sensible default, since you want to be able to write main applications ... http://www.wellho.net/mouth/1404_Tcl ... evel-.html [short article] |
One of the vital topics on all our programming courses is that of variable scope. Variable Scope may be defined as the area of a program in which a variable ... http://www.wellho.net/mouth/96_Variable-Scope.html [short article] |
When you want to pass data INTO a proc in Tcl from a regular variable, you write the variable name with a $ in front of it in the code and the value is ... http://www.wellho.net/mouth/2466_Tcl ... procs.html [short article] |
If you're writing a Tcl proc, you'll normally pass in parameters by value, specifying a $ in front of the variable whos contents you want to pass in in ... http://www.wellho.net/mouth/122_Pass ... n-Tcl.html [short article] |
As your code grows from 1 to 10 to 100 lines, you'll find that it's helpful to split it into a series of logical blocks, each of which can be run as a command. You'll learn how to define such procedures, how to pass information in and out of them, and how to access information that's held in your main program and in the calling procedure too.
This topic is presented on public courses
Learning to program in Tcl,
Tcl Basics
Examples from our training material
| add2 | Answer to final exercise |
| addindemo | Sample code to complete - final exercise |
| cbn | Using upvar to call by name |
| doublit | Another upvar example for learners |
| dr2 | Optional parameter in Tcl |
| dresser | Changing a value within a proc and returning the altered value |
| gsc | The global scope |
| p1 | Sharing a variable using global |
| p2 | Sharing a variable using upvar |
| p3 | Sharing a variable using upvar and call by name - RECOMMENED |
| p4 | returning a variable - RECOMMENED for passing 1 piece of data back |
| p5 | Sharing a variable using uplevel - obscure! |
| pr1 | Defining a proc (command) and using it |
| pr3 | loading a file of procs shared with other applications |
| scope1 | Variable default to being local |
| up1 | Using upvar to effect a variable in the calling code |
| uquery | Shared file of procs |
| uv | Call by value and call by name |
| vardemo | Calling a proc with a variable number of arguments |
| whatandwhen | Exercise - please write the proc to complete |
| wwanswer | First sample answer - "getnumber" |
| wwbetter | Better sample answer - "getnumber" |
Pictures
Radia software is tailored through Tcl procedures
Teaching Tcl around the world
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
Holding commonly used command sequences.
Why use procs?.
Sharing procedures with another application.
Variable parameters.
Variable scope.
The global scope.
The upvar command.
Another example of upvar.
Structured programming and OO.
Structured programming.
Programming with objects.
Use of Procs as an interface to Tcl.
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.