tcl

How to Convert a Tcl Listbox Numerical Indice to its Element

Hello: I feel that this question has a simple answer; but, for the life of me, I could not figure it out. I am trying to convert a listbox selection to its string element so I can enter it into a database. I understand that I can use .listbox curselection to get its index; however, I need to convert it into its string. Can anyone h...

whats the difference between a command and a statement

Often when reading about Tcl (e.g. http://antirez.com/articoli/tclmisunderstood.html) you read that "everything is a command". Sometimes you also hear how other languages are, like Tcl, are "command languages." To me with my background in other languages, I just view these "commands" as statements. What precisely is the difference b...

When was Tcl v8.5 first released for production?

I can't seem to locate this on the web anywhere. What was the date of the first stable release of Tcl v8.5? Thanks. ...

Finding intersection point between plane and line in tcl?

Hi, What is problem with follwoing code? I am getting very strange results. Do I missing something? proc Dot {vec1 vec2} { set ret [expr ([lindex $vec1 0]*[lindex $vec2 0])+([lindex $vec1 1]*[lindex $vec2 1])+([lindex $vec1 2]*[lindex $vec2 2])] } proc FindInterSectPoint_LineAndPlane {normalVectorPlane basePoint refPoint topoint} { fo...

How to handle big integers (64 bit) numbers in tcl?

what is the best way to handle big integers in expr command. we know wide in expr. ...

spawn process in win XP

Hello All I am trying to create a automated ftp log in script in Expect/TCL. This is my script spawn ftp 100.100.100.1 expect ".*:" send "username" expect ".*:" send "password" expect ".*>" I get an error in Windows XP saying , it encountered an error and needs to close . But same thing work on a windows 2000 ....

Importing proc variable into namespace

proc foo {param} { namespace eval foo_ns { uplevel {set foo_ns::x $param } } } This just looks ugly. [upvar] will not work, because it can't link to 'param'. Thanks. Code from answers does not work (tclsh8.4) ------------------------------------------- % proc bar {param} { namespace eval foo_ns { uplevel [list s...

Passing list to Tcl procedure

What is the canonical way to pass a list to a Tcl procedure? I'd really like it if I could get it so that a list is automatically expanded into a variable number of arguments. So that something like: set a {b c} myprocedure option1 option2 $a and myprocedure option1 option2 b c are equivalent. I am sure I saw this before, but I ...

String substitution using tcl API

Is there a way to (ab)use the tcl C-API to 'parse' a string, doing all the replacement (including sub commands in square brackets), but stopping before actually evaluating the resulting command line? What I'm trying to do is create a command (in C, but I'll consider doing a tcl-wrapper, if there's an elegant way to do it there) which ta...

What is difference in several styles for proc syntax in tcl?

Hello, May I know how sytanx of proc affets on its working. in context of -Memory consumption -Argument passing -scope of proc (local/global) proc dosomething {} { #code here } proc dosomething { } { #code here } proc dosomething { #code here } proc dosomething args { #code here } proc ::dosomething {} { #co...

tcl: how to use the value of a variable to create a new variable

here is an example of what I'm trying to do. set t SNS set ${t}_top [commands that return value] Want to get the info stored at ${t}_top puts “${t}_top”  SNS_top (really want the data stored there?) Thought it was : ${{$t}_top} , maybe that was perl but {} inside the {} do not work. ...

How to Store BLOB data in Sqlite Using Tcl

Hello: I have a Tcl TK application that has a Sqlite back-end. I pretty much understand the syntax for inserting, manipulating, and reading string data; however, I do not understand how to store pictures or files into Sqlite with Tcl. I do know I have to create a column that holds BLOB data in Sqlite. I just don't know what to do on ...

tk, tcl exec stderr, stdout separately

I have a tcl script. The problem is that I have to call a script that can write something to stderr (it's not a critical failure). I would like to capture stderr and stdout separately in tk/tcl. if { [catch {exec "./script.sh" << $data } result } { puts "$::errorInfo" } This code will return my result but it also contains stderr....

Opening Excel and PDf files with Tcl Tk

Hello: I am having problems opening an existing Excel file with Tcl Tk. I am able to open an existing MS Word file with no problems. The code that I am using is as follows, also my test application has "package require tcom" included: proc OpenFile {} { #Path to file set app [::tcom::ref getobject "C:\\Users\\Me\\Desktop\\Test.doc"] ...

Getting deadlocks in sqlserver

I am getting deadlocks occasionally in sql server. I created a function for locking non database operations (credit card processing) so duplicates cannot happen. My functions are as follows (sorry for the tcl, but the sql is clear enough). Can anyone see why a deadlock happens occasionally????? proc ims_syn_lock_object { db object {time...

Expect argument handling

I'd like to create an expect script that connects to the server via telnet and does some authorisation. I have a problem with using script parameters though. Based on man I expected this to work: #!/usr/bin/expect -f spawn telnet $argv1 5038 ... Unfortunately I get back can't read "argv1": no such variable. How can make this work? ...

Inheritance with Itcl

I don't understand different behaviour for plain variables and named arrays inherited from base class as visualised by the following example: itcl::class A { variable foo variable FruitBasket constructor {} { array set FruitBasket [list Apple 1 Pear 2 Plums 3] set foo 7 puts "inside constructor of c...

ITCL - How to access associative array member inside a class?

How to access associative array member of a class inside the class itself? Itcl is modeled after C++, and in C++ we would write: SomeObject.SomePublicMember = ... How to do the same in Itcl? Without providing accessor procedure for such an array. I've seen that for usual plain variables this can be obtained by using cget: $this cget ...

Tcl for getting ASCII code for every character in a string

I need to get the ASCII character for every character in a string. Actually its every character in a (small) file. The following first 3 lines successfully pull all a file's contents into a string (per this recipe): set fp [open "store_order_create_ddl.sql" r] set data [read $fp] close $fp I believe I am correctly discerning the ASC...

How do I convert integer to string with leading zeros in Tcl?

I'm learning Tcl. In Perl I can do this: $ perl -e 'for ($i = 0; $i < 5; $i++) { printf("name%03d\n", $i) }' name000 name001 name002 name003 name004 Can I do this in Tcl? ...