On the c.l.t newsgroup, it was noted that there was some interest in creating a Tcl Intro document in the same spirit as perl's perlintro [http://www.perldoc.com/perl5.8.0/pod/perlintro.html]. This is meant to be a quick-and-dirty kind of guide for those who already have a moderate amount of programming experience and are looking to jump in head-first with the help of a few ground rules and examples. Nothing is explained in detail, but there are a few links in the FOOTNOTES that point to other web pages and wiki articles that deal with issues that a new Tcl programmer might stumble into. If you're noticing that this document looks a lot like a [man] page, you're dead on. It would be great if a reference like this could some day be included in the core Tcl distribution or a least a few batteries-included distributions as a man page. Some content (the footnotes in particular) does not follow standard wiki convention... that's because in the end, it needs to be portable to a number of different formats and this particular wiki page will no longer be authoritative. But putting it up here on the wiki while it's still being written makes it easy for anyone to come along and make some constructive changes to it. Very small portions of this document have been adapted from: * [What is Tcl] * The comp.lang.tcl FAQ maintained by Larry Virden: http://www.purl.org/NET/Tcl-FAQ/ (If adapting portions of any of these references is out of line, please let me know and I'll remove the offending parts.) Help is more than appreciated. Like all wiki pages, feel free to edit or add to anything here. I only humbly request that you stay true to the spirit of the document, which primarily means no detailed explanations. Subjects that fall outside of the scope of the Tcl core distribution ([[incr Tcl]], Tk, binary distributions) also fall outside the scope of this document. Please place all discussion between the lines delimiting this section and the document proper rather than ''within'' the document proper. Thanks. --CJU ---- (Discussion goes here.) ---- '''NAME''' tclintro -- a brief introduction and overview of Tcl '''DESCRIPTION''' This document provides a quick introduction and overview of the structure and features of the Tcl programming language. (more explanation needed) '''What is Tcl?''' The name Tcl is derived from "Tool Command Language" and is pronounced "tickle." Tcl is an open-source, interpreted programming language that provides common facilities, such as variables, procedures, and control structures as well as many useful features that are not found in any other major language. Tcl runs on almost all modern operating systems such as Unix, Macintosh, and Windows. While Tcl is flexible enough to be used in almost any application imaginable, it does excel in a few key areas, including: automated interaction with external programs, embedding as a library into application programs, and of course plain old scripting. '''Running Tcl Programs''' Tcl is released as source code. If your operating system is Macintosh or Windows, a third-party binary package is usually the easiest way to install Tcl on your system. Instructions on how to run programs from binary releases are not included in this document--see the documentation included with your particular package for more information. The remainder of this document assumes that Tcl has been installed from source or by the vendor on a Unix system. Tcl scripts are often executed via '''tclsh''', a simple shell containing a Tcl interpreter. If '''tclsh''' is in your path, simply type its name on the command line. '''Tclsh''' takes one optional argument, a filename containing a Tcl script, followed by additional optional arguments that are passed directly to the script: $ tclsh progname.tcl arg1 arg2 You can also make your script executable using '''chmod u+x progname.tcl''' and then adding the following line to the very top of the file: #!/usr/local/bin/tclsh This will do for testing your own scripts, but more portable solutions exist. [[1]] '''Basic syntax overview''' Tcl syntax is extremly simple in that each line consists of a single command followed by an any number of optional arguments. ''command ?arg arg ...?'' Example: puts "hello world" A newline signals the end of a command and its arguments. Commands do not span across multiple lines unless the newline in contained within a pair of grouping characters (either curly braces or double quotes) or when escaped by a backslash. These are explained later. Multiple commands may be placed on a single line by separating them with a semicolon: puts "hello"; puts "world" Comments start with a hash (or pound) symbol and run to the end of the line: # This is a comment The # character must appear at the beginning of the command. If you want to place a comment on the same line as a command to be executed, use a semicolon before the #: puts "hello" ;# Print a greeting. Comments cannot have unmatched braces inside them.[[2]] '''Tcl variable types''' '''Variable scoping''' '''Conditional and looping constructs''' '''Expressions''' '''Files and I/O''' '''Regular Expressions''' '''Writing procedures''' '''Using Tcl Extensions''' '''FOOTNOTES''' 1. [exec magic]: http://mini.net/tcl/812. 1. [Why can I not place unmatched braces in Tcl comments]: http://mini.net/tcl/462 '''AUTHORS''' Charles Ulrich (Add your name here if you've contributed!)