tcl脚本学习四: [] ,“” ,{} 的学习以及嵌套使用

lesson 4

 

1. set x "abc"
puts "A simple substitution: $x\n"
//简单的例子

2. set y [set x "def"]
puts "Remember that set returns the new value of the variable: X: $x Y: $y\n"
//当使用[]的时候,会将 []内的返回值作为y所定义的值

3. set z {[set x "This is a string within quotes within braces"]}
puts "Note the curly braces: $z\n"
//这是括号中引号中的字符串

4. set a "[set x {This is a string within braces within quotes}]"
puts "See how the set is executed: $a"
puts "\$x is: $x\n"
//此时x和a的值均为那个字符串

5.set b "\[set y {This is a string within braces within quotes}]"
puts "Note the \\ escapes the bracket:\n \$b is: $b"
puts "\$y is: $y"
//特别注意:!! \[]将不对[]内进行赋值等一系列操作,直接原封不动作为输出给b

posted @ 2016-08-02 23:08  用不着为这点小事烦恼  阅读(1654)  评论(0编辑  收藏  举报