Dear Reader, this book is an introduction to the main ideas of the Tcl programming language: If you wish to learn a simple and powerful programming language, this book is for you. To read this book, the only prior knowledge needed is some basic understanding of programming in any language: from C, to Python, Perl, Lisp, if you understand the meaning of function and variable and other basic concepts you should not experience problems continuing to read.
A Tcl(Tutorial for Cool Languages) for
This is a very short introduction to the Tcl script language. If you just can't wait, I hope this will make you able to read and to understand simple Tcl code. In many points, Tcl is similar to C, especially for loop structures, function definitions and mathematical or conditional expressions. In other points, such as expression evaluation and list data structures, you will notice that Tcl has inherited from the benefits of the Scheme language.
Tool Command Language
Tcl is a string-based, interpreted command language. Its simplicity in syntax and common sensical approach to semantics makes this an easy language to learn and become proficient in. This short tutorial will concentrate on the most basic concepts to get you started as quickly as possible. The one thing you must remember about Tcl is that it does just what you think it will. The evaluation model is very straightforward. There is a single command and zero or more arguments. Those arguments may in turn be commands with arguments that must be evaluated. The commands' return values become the argument to the original command to be evaluated.
A Non-Programmer's Introduction to
This is a tutorial geared towards all those people who are comfortable with their computer and want to learn how to create some simple (and perhaps not so simple) programs. It is for people who are not programmers but would be interested in becoming such! This won't teach you, but hopefully is a fun and exciting step in the right direction. Note that by far the best resource for this is one of the many fine books available. Go buy one.
Note about the TCL
Tcl stands for "tool command language" and is pronounced "tickle." It is actually two things: a language and a library. First, Tcl is a simple textual language, intended primarily for issuing commands to interactive programs such as text editors, debuggers, illustrators, and shells. It has a simple syntax and is also programmable, so Tcl users can write command procedures to provide more powerful commands than those in the built-in set.
How to use extensions in Tcl
Pure Tcl is both simple and powerful. Very elaborate programs can be built using just Tcl (using tclsh - the Tcl command shell) or Tcl with Tk (using wish - the windowing shell). The apparent simplicity lies in the fact that Tcl performs a script as if the computer understands the commands which form the script. So all you need to do is install the Tcl system on your machine, and bingo... your computer has gained the ability to perform a script written in Tcl. Then, just create or download a script which does what you want and you will be all set.
Tcl, Tool Command Language, is an interpreted language with programming features, available across platforms running Unix, Windows and the Apple Macintosh operating system. Tk, the associated toolkit is an easy and efficient way of developing window based applications. Application tasks are split into modules and any new application specific task is written and compiled as C or C++ program and exported as a new Tcl command. Then a Tcl script, a series of existing and new Tcl commands, is composed to make the overall application. The scripting language, much like any shell language, has the ability to access and execute any other programs. Therefore several Tcl based applications could be made to work together to create or extend into a new application.
Integrating Tcl with the NT Shell
When you install Tcl/Tk on NT, the install program sets up a single file-type for Tcl scripts (.tcl) that executes the script in the Wish interpreter. This means that your scripts cannot interact with the console; e.g: they cannot print to the standard I/O streams and they always execute concurrently with the shell. Additionally, it is impossible to pass command-line parameters to Tcl scripts and you cannot execute scripts by their "base" name in the same way as you can executable programs.
How To Write Tclets
The format of a TclTutor lesson is a short textual description of a command or concept and an interactive example. The lesson text is available in 3 levels of verbosity, "Expert", "Computer User", and "Beginner". The differing levels of verbosity provide a beginner with more information about computer terminology and general programming techniques, while allowing an experienced programmer to get just the minimal information that they need to start using a command. The expert level can be used as a reference tool after you've started using Tcl/Tk regularly.
Practical Programming in Tcl and Tk
Tk is a toolkit for programming graphical user interfaces. It was designed for the X window system used on UNIX systems, and it was ported to the Macintosh and Windows environments in Tk 4.1. Tk shares many concepts with other windowing toolkits, but you do not need to know much about graphical user interfaces to get started with Tk.
Now that you know a little bit about Tcl and Tk it is time to make something. First let's exit our blt_wish with control D. We will attempt to create a simple color viewer looking something like this. The colors may not match yours depending on your color setup. One thing you will need is a scale in fact we need three. A scale is a slider with an associated value. It has a label which can be changed, and a range which can be selected, as well as a length. You can have your slider either horizontal or vertical. The scale can also have an associated command (like a callback) that is run whenever the scale is used.
The formatting of these manual pages varies from package to package because they have been automatically generated from UNIX man pages. Compressed tar files of the HTML are available so you can download them, and older versions are only available this way. Windows users should be able to extract these with Winzip.
Objects in TCL
C++ and Java are two well-known languages that offer primitives and in-language support for object oriented programming. That does not mean that object oriented programming is impossible in other languages. Object orientation is really just a way of thinking; it has more to do with design than with implementation. Look at the source code of the TCL interpreter for a great example of object oriented programming in C (not C++!). If you are disciplined enough to always pass a pointer to a struct as the first parameter to a function, you can see such a function as a 'method' of the struct. You do not need actual language support to create object-oriented code.
Tcl and Java Programming: Practice and Pitfalls
The Tcl-Java tutorial! This tutorial was held at the 1998 Tcl/Tk workshop, September 15th, 1998. The tutorial comes in two versions: the on-line version and the slide version. Tcl Blend and Jacl are interfaces that allow Tcl scripts and Java classes to communicate. Tcl Blend uses the Java Native Interface and is written in C, while Jacl is a Tcl interpreter written in Java. This tutorial shows you how, when, and why to effectively use these interfaces.
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial