A Tcl script consists of one or more commands. Commands are separated by newlines or semicolons. Each command is a set of words, the first word being the command name, and the following being the arguments.
Variables do not have to be declared, they are declared automatically when
you try to set them. To declare a variable you type
set variable value set a 123When you use set, set also returns the value that was just set to the variable. The variables are referenced by $variable. So to use the variable type
puts $a
To write a Tcl procedure you use the proc command.
proc procname {args} {procedure body}
proc plus {a b} {
expr $a+$b
}
Once you have declared the procedure you just call it with the procedure
name and whatever arguments are required, and it will return the value.
plus 1 2Tcl has all the the control structures as any other language (if, while, for, and eval), it also has built in functions for dealing with expressions, lists, and arrays.