首页 > 其他 > 详细

TCL LEARN NOTE V2

时间:2021-05-17 00:33:19      阅读:14      评论:0      收藏:0      [点我收藏+]

TCL LEARN NOTE V2

变量

  1. 变量赋值

    set x 10
    #设定x的值为10
    

    技术分享图片

  2. 计算后变量赋值

    set a 3
    set x [expr $a*3]
    
    #[]相当于bash中$()或``,作为一个单独的命令运行
    

    技术分享图片

  3. 转义后赋值

    set a 3
    set b \$a
    
    #b=$a rather than  b=3
    

    技术分享图片

  4. 变量赋值字符串

  5. 变量的引用

    变量引用需要dollar符
    
    # $variable
    
  6. 替换

    • 命令替换[]
    • 反斜线替换\

打印puts

  1. 打印单个字符

    puts $variable or puts string
    

    技术分享图片

  2. 打印字符串

    打印字符串需要用{},将字符串用{}或“”包起来

    技术分享图片

    If the string has more than one word, you must enclose the string in double quotes or braces ({}). A set of words enclosed in quotes or braces is treated as a single unit, while words separated by whitespace are treated as multiple arguments to the command. Quotes and braces can both be used to group several words into a single unit. However, they actually behave differently. In the next lesson you‘ll start to learn some of the differences between their behaviors. Note that in Tcl, single quotes are not significant, as they are in other programming languages such as C, Perl and Python.
    
    https://www.tcl.tk/man/tcl8.5/tutorial/Tcl1.html
    
  3. 双引号和大括号的区别

    • 双引号允许替换,格式化输出
    • 大括号不允许替换

    技术分享图片

TCL LEARN NOTE V2

原文:https://www.cnblogs.com/movit/p/14775140.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!