Tcl (Tool Command Language, said "tickle") is an interpreted scripting language created by John Ousterhout in 1988. tclsh hello.tcl runs a file and tclsh alone opens an interactive prompt. Its GUI toolkit, Tk, runs scripts under wish.
Tcl · Lesson 1 · On the house
Hello, Tcl: commands, words and set
Run scripts with tclsh, read every line as a command made of words, store values with set and print them with puts. Lesson 1 is free — on the house.
Lessons · Tcl · Lesson 1 of 10 · On the house
Hello, Tcl: commands, words and set
Run scripts with tclsh, read every line as a command made of words, store values with set and print them with puts.

Everything in Tcl is a command. A command is a series of words separated by spaces or tabs: the first word names the command and the rest are its arguments. A newline or a semicolon ends the command.
set name Tcl stores the string Tcl in the variable name, creating it if needed. set name with one argument returns the current value. $name inside a word is replaced by the value.
puts text writes the text and a newline to standard output. puts -nonewline text leaves the newline off, and puts stderr text writes to standard error.
# starts a comment only where a command could start. To comment after code on the same line, end the command first: set x 1 ;# note.
Every value can be treated as a string. Behind the scenes Tcl keeps a faster internal form (integer, list, dict) and converts only when needed, so set n 42 holds something that works as both text and a number.
hello.tcl
# hello.tcl
puts "Hello, Tcl!"
set name Tcl
set major 8
puts "Running $name $major.6"
puts -nonewline "no newline yet"
puts ""
puts [string length $name]
puts {braces keep $name literal}
Quiz
Quiz
Quiz
Quiz
Check
Match the still for: Hello, Tcl: commands, words and set.
Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.