Syntax (also see "man tcl" for a succint and more precise summary) - statements are separated by newlines or semicolons - comments start with # but ;# after a statement - the first word in a statement is the command, the rest the arguments - everything outside double quotes, braces or brackets are split by spaces - each statement is evaluated by first doing 1 substitution pass on each word: - $var becomes the value of the variable var - [...] becomes the result of executing the statement(s) in brackets - backslash can be used to escape special characters - but no substitution occurs when the argument is enclosed in {...} - note that set var 42; puts "\$var is {$var}" prints $var is {42} - if a word starts with {*}, it is removed, and after substitution it is split by whitespace Commands by type |----------------+----------------------------------------------------------------| | Core | | |----------------+----------------------------------------------------------------| | variables | global incr namespace set unset upvar variable | | control flow | break continue for foreach if switch while | | procedures | apply callback proc return tailcall | | evaluation | eval source uplevel | | error handling | bgerror catch error throw try unknown | | other | info interp | |----------------+----------------------------------------------------------------| | Types | | |----------------+----------------------------------------------------------------| | numbers | expr fpclassify | | strings | append encoding format join regexp regsub scan split string | | | subst tcl::prefix tcl_endOfWord tcl_startOfNextWord | | | tcl_startOfPreviousWord tcl_wordBreakAfter tcl_wordBreakBefore | | lists | concat lappend lassign lindex linsert list llength lmap lpop | | | lrange lremove lrepeat lreplace lreverse lsearch lset lsort | | arrays | array parray | | classes | classvariable link my myclass mymethod next nextto oo::* self | | other | binary dict history | |----------------+----------------------------------------------------------------| | Libraries | | |----------------+----------------------------------------------------------------| | loading | auto_import auto_load load package tm unload | | saving | auto_mkindex pkg::create pkg_mkIndex | | other | auto_reset auto_qualify tcl_findLibrary | |----------------+----------------------------------------------------------------| | Environment | | |----------------+----------------------------------------------------------------| | channels | chan close eof fblocked fconfigure fcopy fileevent flush gets | | | open puts read refchan seek tell transchan | | file system | cd file glob pwd zip | | compression | zipfs zlib | | processes | after auto_execok coroinject coroprobe coroutine exec pid | | | tcl::process update yield yieldto vwait | | tcp/ip & http | cookiejar http socket tcl::idna | | time | clock time | | ms windows | dde registry | | meta | memory platform platform::shell rename trace | | other | exit msgcat safe tcltest timerate zip | |----------------+----------------------------------------------------------------| Variables - command line & environment: argc argv argv0 env - error handling: errorCode errorInfo - numbers: tcl_precision - strings: tcl_nonwordchars tcl_wordchars - libraries: auto_path - meta: tcl_interactive tcl_library tcl_patchLevel tcl_pkgPath tcl_platform tcl_rcFileName tcl_traceCompile tcl_traceExec tcl_version Pages with special information - filename : allowed file name conventions - mathfunc : mathematical function recognized by expr (also "::tcl::mathfunc::*") - mathop : mathematical operators recognized by expr (also "::tcl::mathop::*") - re_syntax : regular expression syntax - Tcl : the Dodecalogue