zoukankan      html  css  js  c++  java
  • tcltk 1

    puts


    puts "Hello, World - In quotes"    ;# This is a comment after the command.
    # This is a comment at beginning of a line
    puts {Hello, World - In Braces}
    puts {Bad comment syntax example}   # *Error* - there is no semicolon!
    puts "This is line 1"; puts "this is line 2"
    puts "Hello, World; - With  a semicolon inside the quotes"
    # Words don't need to be quoted unless they contain white space:
    puts HelloWorld


    set
    set X "This is a string"
    set Y 1.24
    puts $X
    puts $Y
    puts "..............................."
    set label "The value in Y is: "
    puts "$label $Y"


    while
    set x 1
    # This is a normal way to write a Tcl while loop.
    while {$x < 5} {
        puts "x is $x"
        set x [expr {$x + 1}]
    }

    for start test next body
    for {set i 0} {$i < 10} {incr i} {
        puts "I inside first loop: $i"
    }


    proc name args body
    proc sum {arg1 arg2} {
        set x [expr {$arg1 + $arg2}];
        return $x
    }
    puts " The sum of 2 + 3 is: [sum 2 3]\n\n"


    lsearch list pattern
        Searches list for an entry that matches pattern, and returns the index for the first match, or a -1 if there is no match. By default, lsearch uses "glob" patterns for matching. See the section on globbing.
    lsort list
        Sorts list and returns a new list in the sorted order. By default, it sorts the list into alphabetic order. Note that this command returns the sorted list as a result, instead of sorting the list in place. If you have a list in a variable, the way to sort it is like so: set lst [lsort $lst]
    lrange list first last
        Returns a list composed of the first through last entries in the list. If first is less than or equal to 0, it is treated as the first list element. If last is end or a value greater than the number of elements in the list, it is treated as the end. If first is greater than last then an empty list is returned.

  • 相关阅读:
    解决端口被占用
    Oracle查询所有表的字段明细
    Spring cron表达式
    Java爬取12306余票
    Activiti工作流框架——快速上手
    ERROR 1045 (28000): Access denied for user 'xxx'@'localhost' (using password: YES)【奇葩的bug】
    一分钟学会JavaMail(假)__手动滑稽
    通过Servlet实现汉字验证码
    使用ServletContext对象读取资源文件
    编写一个简单的java服务器程序
  • 原文地址:https://www.cnblogs.com/greencolor/p/1892492.html
Copyright © 2011-2022 走看看