tcl

How to parse a text file in tcl using separators?

主宰稳场 提交于 2020-01-06 01:35:10
问题 I have a text file of the format 35|46 36|49 37|51 38|22 40|1 39|36 41|4 I have to read the file into an array across the separator "|" where left side will be the key of the array and right side will be the value. I have used the following code foreach {line} [split [read $lFile] \n] { #puts $line foreach {lStr} [split $line |] { if { $lStr!="" } { set lPartNumber [lindex $lStr 0] set lNodeNumber [lindex $lStr 1] set ::capPartsInterConnected::lMapPartNumberToNodeNumber($lPartNumber)

I want to execute awk command from tcl script

烈酒焚心 提交于 2020-01-05 10:27:10
问题 I want to execute the following command from my tcl script exec /bin/awk '/Start/{f=1;++file}/END/{f=0}f{print > "/home/user/report/"file }' input I'm getting this error awk: ^ invalid char ''' in expression is it possible to execute such command from tcl Thanks 回答1: Quote from tcl man page: When translating a command from a Unix shell invocation, care should be taken over the fact that single quote characters have no special significance to Tcl. Thus: awk '{sum += $1} END {print sum}'

tkinter error on python 3 (RuntimeError: Calling Tcl from different appartment)

戏子无情 提交于 2020-01-05 08:53:14
问题 The below code doesn't work on python3.5 (RuntimeError: Calling Tcl from different appartment) But It works well on python 2.7 It is hard to know the reason of problem and how can i fix it. import tkinter import threading class MyTkApp(threading.Thread): def __init__(self): self.root=tkinter.Tk() self.s = tkinter.StringVar() self.s.set('Foo') l = tkinter.Label(self.root,textvariable=self.s) l.pack() threading.Thread.__init__(self) def run(self): self.root.mainloop() app = MyTkApp() app.start(

call questa sim commands from SystemVerilog test bench

删除回忆录丶 提交于 2020-01-05 03:43:15
问题 I want to call questa sim commands like add wave ,add list, write list from my SystemVerilog test bench task add_files_to_list(); add wave -position insertpoint sim:/top/clk add list sim:/top/clk write list -window .main_pane.list.interior.cs.body /home/simulation/top/example.lst endtask but the above doesn't work when i do from system verilog, i have to do i manually from tool. is there any way to do it. or can i call a tcl script from my system verilog code. Thanks 回答1: mti_fli::mti_Cmd(

Regular expression literal-text span

◇◆丶佛笑我妖孽 提交于 2020-01-05 02:58:13
问题 Is there any way to indicate to a regular expression a block of text that is to be searched for explicitly? I ask because I have to match a very very long piece of text which contains all sorts of metacharacters (and (and has to match exactly), followed by some flexible stuff (enough to merit the use of a regex), followed by more text that has to be matched exactly. Rinse, repeat. Needless to say, I don't really want to have to run through the entire thing and have to escape every

Keep mysql connection open

﹥>﹥吖頭↗ 提交于 2020-01-04 12:07:24
问题 I'm making a eggdrop tcl script to write activity of several public IRC channels to a database (over time this will be 10 to 15 channels I think). I have two options how to handle the database connection in mind. An user says something -> Open a mysql connection to the database -> insert information about what the user said -> close the connection Start the bot -> Open a mysql connection to the database -> Insert information when there is channel activity -> Wait for more information etc. I

TCL: Backslash issue (regsub)

家住魔仙堡 提交于 2020-01-04 05:43:10
问题 I have an issue while trying to read a member of a list like \\server\directory The issue comes when I try to get this variable using the lindex command, that proceeds with TCL substitution, so the result is: \serverdirectory Then, I think I need to use a regsub command to avoid the backslash substitution, but I did not get the correct proceedure. An example of what I want should be: set mistring "\\server\directory" regsub [appropriate regular expresion here] puts "mistring: '$mistring'" ==>

How to run a TCL script to tell run in every 10 minutes?

主宰稳场 提交于 2020-01-04 05:18:25
问题 My TCL script: source reboot_patch.tcl set a 1 while {$a < 10} { exec reboot_patch.tcl after 60000 incr a } I need to run "reboot_patch.tcl" script for every 1 min in my system. I wrote above script. But its running only once and its coming out. Following is the "reboot_patch.tcl" script: #!/usr/bin/tcl package require Expect spawn telnet 40.1.1.2 expect "*console." send "\r" expect "*ogin:" send "test\r" expect "*word:" send "test\r" expect "*>" send "clear log\r" expect "*#" send "commit \r

can't read : variable isn't array

邮差的信 提交于 2020-01-04 04:12:04
问题 I have the following code : set arr1(a1) t1 set arr2(a2) t2 set l1 {} lappend l1 arr1 lappend l1 arr2 set arr3(a3) $l1 foreach names [array names arr3] { set value $arr3($names) puts "names = $names, value = $value" foreach ar $value { if {[array exists $ar]} { puts "$ar is an array" foreach {key val} [array get $ar] { set d1 $ar($key) puts "ar key = $key value = $val " } } } } but when I run the tcl script it fails for the line "set d1 $ar($key)" . The error msg is 'can't read "ar(a1)":

How make proc more effective?

余生长醉 提交于 2020-01-04 04:06:07
问题 There is a collection of vertices: [ x1 y1 x2 y2 .. xn yn ] I would like to change the center of those coordinates. So I try: proc changeCenter { vertices X Y } { set myList [list] foreach element $vertices { lappend myList [expr [lindex $element 0] + $X] lappend myList [expr [lindex $element 1] + $Y] } return $myList } But its performance too slow. How can I change above code to be more effective or maybe need to change the representation of vertices? 回答1: Your changeCenter proc indicates