<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## 輸出到終端,盡量使用雙引號 ``` puts "hello,world" ``` ## 多行注釋 ``` if 0 { 這是第一次使用tcl } puts "上面是多行注釋" ``` ## 查看版本號 ``` puts "version:$tcl_version" ``` ## 環境路徑 ``` puts "環境路徑$env(PATH)" ``` ## tcl啟動文件 ``` puts "啟動文件:$tcl_rcFileName" ``` ## 數學計算 Tcl默認精度為12位 可以使用tcl_precision特殊變量改變精度 ``` puts [expr 1 + 1 + 5] ``` ## 變量,字符串(list) ``` set var 24 set str {mstring a b c} puts "$var:[lindex $str 1]" ``` ## 關聯數組(如同哈希表) ``` set marks(english) 80 puts english:$marks(english) set marks(mathematics) 90 puts mathematics:$marks(mathematics) ``` ## 動態類型,數據類型自動轉換 ``` if 0 { TCL是一種動態類型語言。 變量的值可以在需要時被動態地轉換為所需的類型。 例如,一個數字5,其被存儲為字符串將做的算術運算時被轉換為數字。 } set variableA "10" puts $variableA set sum [expr $variableA +20]; puts $sum ``` ## tcl的運算符和c語言基本一樣 只有一些細微差別 ``` set a 21 set b 10 set c [expr $a + $b] puts "Line 1 - Value of c is $c\n" set c [expr $a - $b] puts "Line 2 - Value of c is $c\n" set c [expr $a * $b] puts "Line 3 - Value of c is $c\n" set c [expr $a / $b] puts "Line 4 - Value of c is $c\n" set c [expr $a % $b] puts "Line 5 - Value of c is $c\n" ``` ### 注意else的位置和條件是用大括號括起來的 ``` if {10 > 5} { puts "a大于c" } else { puts "a不大于c" } if {!10 || 5} { puts "true" } else { puts "false" } set d [expr 2>3?2 : 3] puts $d set a 100 #check the boolean condition if { $a == 10 } { # if condition is true then print the following puts "Value of a is 10" } elseif { $a == 20 } { # if else if condition is true puts "Value of a is 20" } elseif { $a == 30 } { # if else if condition is true puts "Value of a is 30" } else { # if none of the conditions is true puts "None of the values is matching" } puts "Exact value of a is: $a" ``` ## case語句 注意空格 ``` set grade 2 switch $grade { 1 { puts "grade=1" } 2 { puts "grade=2" } 3 { puts "grade=3" } default { puts "grade=10" } } ``` ## for 循環 ``` for { set a 10} {$a < 20} {incr a} { puts "value of a: $a" } ``` ## 數組 ``` set languages(0) Tcl set languages(1) "C Language" puts $languages(0) puts $languages(1) puts [array size languages] ``` ## 函數 ``` proc helloWorld {} { puts "Hello, World!" } helloWorld proc add {a b} { return [expr $a+$b] } puts [add 10 30] ``` ## 文件操作 ``` set myfile [open "t.txt" w+] puts $myfile "我好細化你" puts $myfile "超級大保健" close $myfile set fp [open "t.txt" r] set file_data [read $fp] puts $file_data close $fp ``` [基礎教程](https://www.yiibai.com/tcl/tcl_regular_expressions.html#article-start)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看