- String Manipulation:
-
regexp format split string
regsub scan join
- File I/O:
-
open gets seek flush glob
close read tell cd
puts source eof pwd
- Error Handling:
-
catch error errInfo
- Subprocesses:
-
exec grep foo << $input | wc
- Associative Arrays:
-
set x(fred) 44
set x(2) [expr $x(fred) + 6]
- Variable Scoping:
-
global uplevel upvar
- Access to Tcl internals:
-
info rename trace
- Autoloading:
-
- The unknown procedure is invoked when a command doesn't exist.
- Loads procedures on demand from libraries.
- Uses a search path of directories.
- More on substitutions:
-
- Commands and Lists:
-
- Lists parse cleanly as commands: each element becomes one word.
- To create commands safely, use list commands:
- button .b -text Reset -command {set x $initValue}
-
Oops! initValue read later, when button invoked.
- ...-command "set x $initValue"
-
Oops! Fails if initValue contains ``New York''
- ...-command "set x {$initValue}"
-
Oops! Fails if initValue contains ``{''
- ...-command [list set x $initValue]
-
OK. Always works.