This is a page for people interested in learning how to program using tcl and Tk.

Lets get straight into Tool Command Language ( tcl ).
If you are in Puppy click on rxvt and type in

wish

you should have a window open on the desktop named wish and the # prompt should have changed to a %.

Now for the classic ' Hello World! ' program, type

puts "Hello World!" and hit enter

Hello World! should appear at the prompt.

Congratulations, you have just written your first tcl program.

To dissect this lets look at what happened.
First you opened the tcl wish shell and then entered a command ' puts'.
This prints to the standard output which is the terminal that you are working in.
What it outputs is the text enclosed by the " " .

Calculations are done with the command expr:
Type:

expr 1+2

and Tcl will respond with "3".

To force calculation in floating-point, add a decimal point:

expr 17/4.0

Assign and use a variable:

set x 17
puts "x=$x"

set t1 Hello
set t2 "Good morning"
puts "$t1, $t2"

A complete, simple example:

set x 17
set y 4.0
set z [expr $x/$y]
puts "$x/$y=$z"

The square brackets above are used to group the result that gets assigned to z.

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

tcl/Tk more info

Tcl is an interpreted language which means that you do not have to run it through a compiler to create a program,
you can write a tcl program and run it to see the results immediately.
Tcl is composed of built in commands and commands you can create yourself called procedures
which use the name proc and are what you could call sub-programs or macros.

Here is an example of a small procedure that calculates the square of its argument,
and a loop to output a simple table:

Tk is the Tool kit used by tcl and is used to create "windows" to view and display information and graphics.
The main window that you create is represented by a period . and any frames or widgets created
inside that window start with a . so if a frame is created to contain text
you could name it something like .txt and any text entered would be referenced to .txt as in:

package require Tk
text .txt
pack .txt
.txt insert end "Hello World!"

which means define a text-frame named ".txt", use the packer to put it into the window .,
then insert the strings "Hello World!" at the end of the text frame.

To make this Tk-example somewhat interactive, we can add two buttons to the above code: