(4)、string length string 返回字符串的长度,空格、换行符(\n整体算做一个字符)也算一个字符example: (5)、string index string charIndex 返回string中的第charIndex个字符,charIndex可以为: —整数n :第n个字符(从0开始,下面简记为0-based) —end :最后一个字符 —end-整数n:倒数第n个字符【倒序】 如果...
(4)、string length string 返回字符串的长度,空格、换行符(\n整体算做一个字符)也算一个字符example: (5)、string index string charIndex 返回string中的第charIndex个字符,charIndex可以为: —整数n :第n个字符(从0开始,下面简记为0-based) —end :最后一个字符 —end-整数n:倒数第n个字符【倒序】 如果...
Example : set str "This is a string" puts "The string is: $str" puts "The length of the string is: [string length $str]" puts "The character at index 3 is: [string index $str 3]" puts "The characters from index 4 through 8 are: [string range $str 4 8]" puts "The index...
The string is: This is a string The length of the string is: 16 The character at index 3 is: s The characters from index 4 through 8 are: is a The index of the first occurrence of letter "i" is: 2 eval 调用一个Tcl脚本 eval命令会把它的参数直接送往解释器。 Example 9.1: set foo ...
9:: How to check whether a string is palindrome or not using TCL script? Code for the above pseudo code.Check if it works!!! gets stdin a set len [ string length $a ] set n [ expr $len/2 ] for { set i 0 } { $i < $n } { incr i 1 } { set...
proc process_data {data} { set result {} foreach item $data { lappend result [expr {[string length $item] * 2}] } return $result } set test_data [lrepeat 1000 "sample"] set proc_time [time {process_data $test_data} 100] puts "Procedure execution time: $proc_time" ...
Scan command is used for parsing a string based to the format specifier. Some examples are shown below. Live Demo #!/usr/bin/tclshputs[scan"90"{%[0-9]}m]puts[scan"abc"{%[a-z]}m]puts[scan"abc"{%[A-Z]}m]puts[scan"ABC"{%[A-Z]}m] ...
Laker TCL 基础训练教材
# monitor resolution ratio , for example : 1920 x 1080 quietly set m_width 1920 quietly set m_height 1080 if 0 { my first program in Tcl program Its very simple } 首先,第一行,TCL 采用#进行单行注释,多行注释使用判断句注释,就像末尾的 if 那样。TCL 是一种弱语言类型,不需要声明类型,直接通...
string equal "This is a TCLTK example" "This is a tcltk example";#不同返回0 string equal "This is a tcltk example" "This is a tcltk example";#相同返回1 搜索字符串 string first "tcltk" "This is a tcltk example";#返回10,返回第一次匹配的索引,如果找不到则返回-1 ...