string compare和stringequal都是区分大小写的,但如果添加选项-nocase,则不再区分大小写,如下图所示。 还可以通过-length选项指定对字符串的前length个字符进行比较操作,如下图所示。这里可以看到-length的在命令中的正确位置。 尽管字符串比较支持直接使用数学表达式(> 、<和==),但从代码风格和执行效率的角度而言,...
puts"Item at index 2 of the list{$x} is : [lindex$x2]\n";#创建列表ysety {split"12/3456""/4"}; puts"The length of the list{$y} is : [llength$y]\n";#创建列表zsetz [list puts"arg 2 is$y"]; puts"A command resemble :$z\n";#创建列表msetm [concat a b {cd} {e f...
…TCL(Tool Command Language)语言是一种高级脚本语言,以其灵活性、可扩展性和易于嵌入其他应用程序中...
array get 命令 array get 命令提取数组索引、元素值对并将这些值对组织成一个列表。而 array set 命令 则将一个列表(数据要成对)转换成一个数组。例 array names命令 array names 返回所有元素索引名与模式 pattern 匹配的元素索引名列表。模式 pattern 和 string match 的模式格式相同。如果 pattern 没有指定,...
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命令会把它的参数直接送往解释器。
{01234}01234**(tcl)>**setlength[llength$list1]5**(tcl)>**if{length > 3}{> puts"The length of list1 is larger than 3">}elseif{length==3}{> puts"The length of list1 is equal to 3">}else{> puts"The length of list1 is less than 3">}The length of list1 is larger than...
与list相关的一些指令 1、llength list llength list返回list的元素个数 ? 2、lindex ?index…? lindex ?...将list中从first到last的元素换成0个或多个元素,该指令可以用来替换、删除元素 ? 6、lset varName ?index…? newValue lset varName ?...把value作为列表元素添加到varName变量中,如果这个变量不...
string length$qian; #将返回变量qian的长度 6、数字操作:因为tcl中只有一个string类型的变量,所以当要操作数字进行运算的时候,tcl提供了incr和expr两个操作数。 incr的基本用法为: incrvariable integer(variable必须为数字) 例如我要将一个数字加3 set a 3; ...
33、;is:stringfirsti$str"Output:Thestringis:ThisisastringThelengthofthestringis:16Thecharacteratindex3is:sThecharactersfromindex4through8are:isaTheindexofthefirstoccurrenceofletter"i"is:2Input/OutputTcl的绝大多数输入/输出是通过puts和gets做到的。Puts命令显示在console上,gets命令从console输入上取得数据,并...
set surfmeshnumberstr [string length $surfmeshids] *startnotehistorystate {Automesh surfaces} set shuzu 0 set xuhao 0 for {set rm 0} {$rm<$surfmeshnumberstr} {incr rm 1} { set temp [string index $surfmeshids $rm] if {$temp==" "} { ...