tcl

Running TCL code (on an existing TCL shell) from Python

我与影子孤独终老i 提交于 2020-01-07 04:21:27
问题 Introduction I recently started working on a legacy product, under Linux, which incorporates a builtin TCL shell. Due to company limitations, I can't gain control to "behind the scenes" and all of the code I can write must be run under this TCL shell, handling the pre-defined clumsy TCL API of the product. I found myself wondering a few times whether it will be possible to patch some Python into this setup, as some solutions seem more legitimate in Python than in TCL. By patching Python I

Call different interpreter for Tcl in python

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-06 15:25:34
问题 I wish to run a Tcl script with a different interpreter (OpenSees) from python itself, similar to this question, what would be the most practical way? I've tried tkinter and subprocess routines but as far as I understand i'm running the script in pure Tcl and nothing happens (functions are defined in the OpenSees environment). I've tried calling my Tcl script via tkinter and but I can't for the life of me figure out how to run tcl with another interpreter, what i've tried is: for-test.tcl

Expect Script to Send Different String Outputs

只愿长相守 提交于 2020-01-06 14:51:09
问题 I have something like this. expect "hi" { send "You said hi\n" } "hello" { send "Hello yourself\n" } "hi" { send "2nd time you said hi\n" } The scenario is I will get a initial response 'hi', then 'hello', then 'hi' again. The second time I get a response of 'hi', I want to send a different string. Thanks. 回答1: You should use a list and iterate... set responses {{You said hi} {2nd time you said hi}} set idx 0 while {$idx < [llength $responses]} { expect { "hi" { send [lindex $responses $idx]

Free compiler or interpreter for TCL, and TCL serial port (COM1) commands

爷,独闯天下 提交于 2020-01-06 14:36:08
问题 1) Is there any freeware which combine tcl editor and compiler (or interpenter)? 2) After opening of the serial connection (COM1) using fconfigure , how can I send via the connection, a string of several words? I need to connect to some HW and I want to be able running a scripts on its CLI. Thanks 回答1: Is there any freeware which combine tcl editor and compiler (or interpenter)? The Tcl source code is thoroughly openly available. Download and build to get an “interpreter” (actually, it

Color of Radiobutton in Tcl/Tk 8.5

这一生的挚爱 提交于 2020-01-06 07:09:28
问题 is it possible to modify the color of a radiobutton's dot (i.e. only the fill-color of the diamond/circle)? I am already using the classic theme, in order to get the old diamonds. But unfortunately, the fill-color of those diamonds is always some red and I need bright green. Is that possible? Maybe by creating an own widget that "inherits/extends" the basic radio button? Any kind of advice is welcome. Kind regards, mefiX 回答1: The radiobutton command has -selectcolor option. Just specify the

Converting Columns in a List in Tcl Script

夙愿已清 提交于 2020-01-06 05:52:08
问题 I want to convert a column of a file in to list using Tcl Script. I have a file names "input.dat" with the data in two columns as follows: 7 0 9 9 0 2 2 1 3 4 And I want to convert the first column into a list and I wrote the Tcl Script as follows: set input [open "input.dat" r] set data [read $input] set values [list] foreach line [split $data \n] { lappend values [lindex [split $line " "] 0] } puts "$values" close $input The result shows as: 7 9 0 2 3 {} {} Now, my question is what is these

Segmentation fault after running vectore based forwarding protocol in aqua-sim

微笑、不失礼 提交于 2020-01-06 04:45:20
问题 can someone please help me trace this error, i'm using vector based forwarding protocol tcl example on 400 nodes and i got this error UWSink (id:0): I get the packet data no.0 from 378 SK 0: Num_Recv 412, InterArrival 0.298128 UWSink (id:0): I get the packet data no.11 from 262 SK 0: Num_Recv 413, InterArrival 0.057902 UWSink (id:0): I get the packet data no.4 from 79 SK 0: Num_Recv 414, InterArrival 0.368108 UWSink (id:0): I get the packet data no.10 from 79 SK 0: Num_Recv 415, InterArrival

Embedded Tcl: Does Tcl autocomplete commands?

限于喜欢 提交于 2020-01-06 04:08:04
问题 We have a Tcl built in our C/C++ application, I found the place in our code where Tcl_EvalObjv is called if the command was not found. I have to admit that the code is pretty old and not many of our developers know what happens in this module. It looks like this: // ... there is some checking if command is registered etc., it fails and the code goes here: std::vector<Tcl_Obj*> tclArgs = { NULL }; for (int i = 1; i < objc; ++i) tclArgs.push_back(objv[i]); tclArgs.shrink_to_fit(); // ...

TCL Regular Expression

一世执手 提交于 2020-01-06 03:03:13
问题 I have two types of interfaces "Ethernet9/12/1 and Ethernet8/34". I wanted to parse both type of interfaces using single regular expression. I was trying to achieve this in the below manner: set int "Ethernet9/12/1" regexp -nocase "(.*t)((\\d+)\/(\\d+)/\(\\d+))" $int - int_type int_num mod_num port broken_port puts $int_type puts $int_num puts $mod_num puts $port puts $broken_port This code works for Ethernet9/12/1. But, the same regexp does not work for Ethernet8/34. I need help to achieve

How to parse a text file in tcl using separators?

廉价感情. 提交于 2020-01-06 01:35:27
问题 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)