Tcl Cheat Sheet
cheat-sheet tcl- 基础语法
1puts "Hello World"#输出
2set x [expr 1 == 2 ? 1 : 2]#设置变量;三元运算符
3[exec ls]#调用子进程
4
5#if
6if { $x < 2} { ... }
7elseif { $x == 1 } { ... }
8
9#while
10while { $x < 2 } {
11 incr x
12}
13
14#for
15for { set i 0 } { $i < 5 } { incr i } { ... }
16
17#switch
18switch $x {
19 1 { ... }
20 2 { ... }
21 default { ... }
22}
- 字符串
1set s1 "_Hello_World_"
2set s2 "_"
3
4[string length $s1]
5[string index $s1 0]
6[string range $s1 1 end]
7append s1 …













