tcl

Deal with download interruptions in Tcl

I'm downloading a list of files using tcl's http package and was wondering what the best way to handle interruptions are. Right now the outline to my download procedure looks like this: proc downloadFiles {url_list folder_location} { foreach {i} $url_list { regsub {.*/(.*)$} $i {\1} $name set out [open $folder_locati...

automating ssh login: tcl expect interact comand behaves weird

I wanted to automate ssh logins. After some research, it seemed like tcl/expect was the route to go. However, my issue is that when interact takes over my terminal, stuff doesn't work as expected (pun not intended). For example, if I resize the terminal, it does not "take". Also, sometimes the interact is not responsive, and sometimes...

Using TCL extensions to set native window style in Tkinter

pythonware.com/library/tkinter/introduction/… documents a overrideredirect method that will remove thetitlebar and borders, if that is not enough you must set the native window style, I'm not sure if Tkinter gives you that kind of low-level access, if not, try the something like twapi.magicsplat.com/ui.html#set_window_...

How to unpack a list into variables in Tcl?

In Python I can write something like: my_list = [4, 7, "test"] a, b, c = my_list After that a is 4, b is 7 and c is "test" because of the unpack operation in the last line. Can I do something like the last line in Tcl? To make it more clear, I want something like that: set my_list {4 7 test} setfromlist $mylist a b c (I.e. setfroml...

problem with utf-8 windows versus Mac

OK, I have a small test file that contains utf-8 codes. Here it is (the language is Wolof) Fˆndeen d‘kk la bu ay wolof aki seereer a fa nekk. DigantŽem ak Cees jur—om-benni kilomeetar la. MbŽyum gerte ‘pp ci diiwaan bi mu that is what it looks like in a vanilla editor, but in hex it is: xxd test.txt 0000000: 46cb 866e 6465 656e 2064 ...

How would an irc bot written in tcl stack up against a python/node.js clone?

I believe eggdrop is the most active/popular bot and it's written in tcl ( and according to wiki the core is C but I haven't confirmed that ). I'm wondering if there would be any performance benefit of recoding it's functionality in node.js or Python, in addition to making it more accessible since Python and JS are arguably more popular...

In Tcl is whitespace equal to Empty string?

I am using the switch statement to match some options which may or may not have VALUES associated with them, then extracting the values (which I imagine could be nothing or just a bunch of empty strings). In Tcl are these equivalent? I.e. will trailing white space be fed as an option or parsed out? Should I "string trim" the value or i...

How to initialize an array in Tcl?

What is the proper way to initialize an empty array in Tcl? I have the following code (simplified): proc parseFile {filename results_array} { upvar $results_array results set results(key) $value } set r1 {} parseFile "filename" r1 and I get the error: Error: can't set "results(key)": variable isn't array ...

How to use option key combinations in a text widget

On a Mac I can get an a-grave character by typing Option+` followed by a - voilà ! When using a text widget however, the Option+` combination causes wish to quit unexpectedly. Is there a way to get around this? Is there a binding that will take care of this, and allow me to insert a character into the text. The language I am dealing wi...

TCL Regular Expression Doubt

Hi, As per my understanding of RE --> * means matches 0 or more occurrences of prev regex --> + means matches 1 or more occurrences of prev regex Now lets take a look at the following examples FIRST:- % regexp {:+} "DHCP:Enabled" first 1 % puts $first : --> ":" is stored in variable first % SECOND:- % regexp {...

How put Block Comments in TCL

I have code here proc checkPrime {no} { set i 1 set count 0 while {$i < $no} { if {{$no%$i} eq 0} { incr count } if {$count eq 2} { puts "the number is prime number" return } incr i } } i want put the whole procedure into a single c...

How do I extract all matches with a Tcl regex?

hi everybody i want solution for this regular expression, my problem is Extract all the hex numbers in the form H'xxxx, i used this regexp but i didn't get all hexvalues only i get one number, how to get whole hex number from this string set hex "V5CCH,IA=H'22EF&H'2354&H'4BD4&H'4C4B&H'4D52&H'4DC9" set res [regexp -all {H'([0-9A-Z]+)&} ...

Use google translate to translate printf-based string

I'm trying to use the web-based google translate to translate my english files to another language. They contains characters like %s and %d. Is there a way to protect them from being erroneously translated. For instance, the text: Athlete already exists with number %s is translated to: Athlète existe déjà avec nombre% s whil...

how to extract a single digit in a number using regexp

set phoneNumber 1234567890 this number single digit, i want divide this number into 123 456 7890 by using regexp. without using split function is it possible? ...

how to identify odd 1's in a binary number

hi , how to identify odd 1's in a binary number my binary numbers is, i.e every odd bit is a 1 in binary number 1 1 0 0 1 0 0 0 1 0 1 0 1 0 1 1 1 1 1 1 0 1 1 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 11010101010101111110110 11101101010101100011011 11111100110101010111101 i want get output what bit ...

Tcl/Tk: Maximize window / determine if window is maximized?

Can I find out if my toplevel window is maximized, and can I maximize it programmatically? I am using R's tcltk package 8.5 on Windows XP. The reason for the question is: I want to enforce a <Visibility> event by calling first withdraw and then deiconify. However, if the window was maximized before these two function calls, it is not af...

Simple XOR a message (Javascript/Tcl)?

I need the username/password to be scrambled at the client-side before sending it over via HTTP GET/POST. And the server will decode it with Tcl, before the checks against database. Currently I'm thinking about using JavaScript for the client-side. Java Applet will also do. Is there any way, that I can easily achieve it, using Simple X...

Tcl [list a b c] vs {a b c} is there a difference and in what context?

Hello, I'm playing around with Tcl and have found several scenarios where [list a b c] is interchangeable with {a b c}. What is the preferred method, and where does [list a b c] fail to match the behavior of {a b c}? ...

TCL: Return to a higher level?

How can I return from a proc to a higher context? For example: If proc X called another proc Y which called a third proc Z - is there a way to return from Z directly back to X ? ...

passing arrays to functions in tcl. Only upvar ?

As far as I understand, in tcl if you want to pass a named array to a function, you have to access the upper scope of the caller via the upvar command within the callee body. Is this the only way to pass an array in tcl ? ...