The traditional starting place for programming discussions is the classic "Hello, World" program. Once you can print out a string, you are prepared to conquer the world (of programming).

The command to output a string in Tcl is the 'puts' command.

A single unit of text after the puts command will be printed to the standard output device (in this case, the lower window). The default behavior is to move the cursor to the beginning of the next line after printing out a line of text, instead of leaving the cursor at the end of the text.

If the string has more than one word, you must enclose the string in quotes or braces ({}). A set of words enclosed in quotes or braces is treated as a single unit, while words separated by whitespace are treated as multiple arguments to the command. Quotes and braces can both be used to group several words into a single unit, however, their behavior isn't identical. In the next lesson you'll start to learn some of the differences between their behaviors.

If you do not enclose a string in braces or quotes, then the string will be interpreted as several arguments instead of as one argument. Many commands in Tcl (including puts) can accept multiple arguments. If the string is not enclosed in quotes or braces, then the separate words in the command will interpreted as separate arguments, by the Tcl interpreter, which will pass the argument to the puts command. The puts will try to evaluate these words as optional arguments, which will probably result in an error.

A command in Tcl is a list of words terminated by a newline or semicolon. Comments in Tcl have a # in the position where a command could be. Some commands in Tcl may contain multiple words, so in order to put a comment on a line after a command the comment must be preceded by a semi-colon, to terminate the command.

My personal style is to always use the ;# for comments.

For now, run the example, and try modifying the string a little to get familiar with the tutorial system, and running scripts. When you are comfortable with the puts command, click Next Lesson to continue.