Sie sind auf Seite 1von 2

Tcl Quick Reference Card

(for version 7.3 )

Basic Language
Features
; or newline
statement separator
#
var
var(index)
var(i,j)
$var
$fvargxyz
[expr 1+2]
n$
\hello $a"
fhello $ag

comment
simple variable
associative array variable
multi-dimensional array variable
variable substitution
variable substitution
command substitution
backslash substitution (see below)
quoting with substitution
quoting no substitution (deferred evaluation)

nb
nf
nn
nr
nt
nv
nspace
nnewline
nddd
nxdd
nc

backspace (0x8)
form feed (0xC)
newline (0xA)
carriage return (0xD)
horizontal tab (0x9)
vertical tab (0xB)
space
space
octal value (d=0-7)
hexadecimal value (d=0-9, a-f)
replace `nc' with `c'

argc
argv
argv0
auto path
env
errorCode
errorInfo
tcl interactive
tcl precision
tcl prompt1
tcl prompt2

command line arguments (list)


command name
path for autoloaded commands
environment variables (array)
information on last error (list)
stacktrace after error
set to 1 if running interactive Tcl shell
number of signi cant oating point digits
prompt string
prompt string for incomplete commands

Backslash
Substitutions
na
audible alert (0x7)

Built-In Variables
number of command line arguments

Library Procedures

auto execok cmd


auto load cmd
auto mkindex dir pattern pattern ...
auto reset
parray arrayName
unknown cmd ?arg arg ...?

Written by Je Tranter 29-Jun-1994

Operators
(inunary
decreasing
precedence)
~!
minus, bitwise NOT, logical NOT

*/%
+-

multiply, divide, remainder


add, substract
<< >>
logical left and arithmetic right shift
<> <= >=
boolean comparisons
== !=
boolean equal, not equal
&
bit-wise AND
^
bit-wise exclusive OR
j
bit-wise inclusive OR
&&
logical AND
jj
logical OR
x? y: z
if x != 0 then y, else z
All operators support integers. All support oating point except ~, %, <<, >>, &, ^, and j. Boolean operators can also
be used on strings.

Math
Functions
abs
absolute value

acos
asin
atan
atan2
ceil
cos
cosh
double
exp
oor
fmod
hypot
int
log
log10
pow
round
sin
sinh
sqrt
tan
tanh

arc cosine
arc sine
arc tangent
arc tangent of x=y
round up to nearest integer
cosine
hyperbolic cosine
convert to oating point

regex*
regex+
regex?
.
^
$
nc
c
[abc]
[^abc]
[a-z]
[^a-z]
()

match zero or more of regex


match one or more of regex
match zero or one of regex
any single character except newline
match beginning of line
match end of line
match character c
match character c
match set of characters
match characters not in set
match range of characters
match characters not in range
group expressions

ex

round down to nearest integer


oating point remainder of x=y
x2 + y2
convert to integer by truncation
natural logarithm
base 10 logarithm

p
xy

convert to integer by rounding


sine
hyperbolic sine
square root
tangent
hyperbolic tangent

Regular
Expressions
regexjregex
match either expression

Filename
Globbing
?
match any single character

*
match zero or more characters
[abc]
match set of characters
[a-z]
match range of characters
nc
match character c
fa,b,...g
match any of strings a, b, etc.
~
home directory
~user
match user's home directory
A \." at the beginning of a le's name or just after \/" must
be matched explicitly. All \/" characters must be matched
explicitly.

Features
of exec
Command
j
pipe (stdout)
j&

< leName
<@ leId
<< value
> leName
2> leName
>& leName
>> leName
2>> leName
>>& leName
>@ leId
2>@ leId
>&@ leId
&

pipe (stdout and stderr)


stdin from le
stdin from open le
pass value to stdin
stdout to le
stderr to le
stdout and stderr to le
append stdout to le
append stderr to le
stdout and stderr to le
stdout to open le
stderr to open le
stdour and stderr to open le
run in background

Built-In Commands

append varName value ?value value ... ?


array anymore arrayName searchId
array donesearch arrayName searchId
array names arrayName
array nextelement arrayName searchId
array size arrayName
array startsearch arrayName
break
case - obsolete, see switch
catch script ?varName?
cd ?dirName?
close leId
concat ?arg arg ...?
continue
eof leId
error message ?info? ?code?
eval arg ?arg ...?
exec ?switches? arg ?arg ...?
?switches? = -keepnewline or - exit ?returnCode?
expr arg ?arg arg ...?
le atime name
le dirname name
le executable name
le exists name
le extension name
le isdirectory name
le is le name
le lstat name varName
le mtime name
le owned name
le readable name
le readlink name
le rootname name
le size name
le stat name varName
le tail name
le type name
le writable name
ush leId
for start test next body
foreach varName list body
format formatString ?arg arg ...?
gets leId ?varName?
glob ?switches? pattern ?pattern ...?
?switches? = -nocomplain or - global varName ?varName ...?
history
history add command ?exec?
history change newValue ?event?
history event ?event?
history info ?count?
history keep ?count?
history nextid
history redo event
history substitute old new ?event?

history words selector ?event


if expr1 ?then? body1 elseif expr2 ?then? body2 elseif ... ?else?
?bodyN?
incr varName ?increment?
info args procName
info body procName
info cmdcount
info commands ?pattern?
info complete command
info default procname arg varname
info exists varName
info globals ?pattern?
info level ?number?
info library
info locals ?pattern?
info patchlevel
info procs ?pattern?
info script
info tclversion
info vars ?pattern?
join list ?joinString?
lappend varName value ?value value ...?
lindex list index
linsert list index element ?element element ...?
list ?arg arg ...?
llength list
lrange list rst last
lreplace list rst last ?element element ...?
lsearch ?mode? list pattern
lsort ?switches? list
open leName ?access? ?permissions?
pid ? leId?
proc name args body
puts ?-nonewline? ? leId? string
pwd
read ?-nonewline? leId
read leId numBytes
regexp ?switches? exp string ?matchVar? ?subMatchVar ...?
?switches? = -indices, -nocase or - regsub ?switches? exp string subSpec varName
?switches? = -nocase or - rename oldName newName
return ?-code code? ?string?
return -code error ?-errorinfo info? ?-errorcode code? ?string?
scan string format varName ?varName ...?
seek leId o set ?origin?
set varName ?value?
source leName
split string ?splitChars?
string compare string1 string2
string rst string1 string2
string index string charIndex
string last string1 string2
string length string
string match pattern string
string range string rst last
string tolower string

string toupper string


string trim string ?chars?
string trimleft string ?chars?
string trimright string ?chars?
switch ?options? string pattern body ?pattern body ...?
switch ?options? string fpattern body ?pattern body ...?g
?options? = -exact, -glob, -regexp or - tell leId
time script ?count?
trace variable name ops command
trace vdelete name ops command
trace vinfo name
unknown cmdName ?arg arg ...?
unset name ?name name ...?
uplevel ?level? arg ?arg ...?
upvar ?level? otherVar myVar ?otherVar myVar ...?
while test body

Das könnte Ihnen auch gefallen