2012-05-04 31 views
0

我有一個名單說測試如何獲得指針的位置列表

set test "Hi i am Nitesh" 
regexp "am" $test 
tell test # to ge the position of the pointer 

我得到一個錯誤

can not find channel named "test" 

不知道該怎麼做

回答

3

看起來你在這裏有兩個完全不同的概念。一方面你有一個列表,你想在列表中找到一個術語的位置。然後,另一方面,您正在使用告訴(通常用於確定打開通道的訪問位置)。我懷疑你真正需要的是搜索名爲test的字符串。嘗試使用http://www.tcl.tk/man/tcl8.5/TclCmd/string.htm#M8

set test "Hi i am Nitesh" 
string first "am" $test 

如果你要正確對待測試的名單,然後只需使用lsearch找到列表索引。

lsearch $test am 
+0

我同意。 @Nitesh,看起來你甚至懶得去看「regexp」和「tell」手冊頁。 – kostix

+0

@Nitesh,我是否已經充分回答了您的問題,還是需要更多幫助? – TrojanName