Version 30 of Peter Newman

Updated 2004-10-31 04:09:52 by CMCc

EDIT/RECENT CHANGES


Mail

Robert Abitbol

Apart from seing de visu that you are a creative, hard-working, competent, polite and reliable young man, I don't know much else about you. Why don't you have your homepage here and why don't you tell us more about you?

Or if you don't want to give information publicly, you can e-mail me. I'd be honoured to receive an e-mail from you. I'm: [email protected]. You can also call me on AIM if you wish. I'm: pnb120.

Hope to hear from you!


Robert Abitbol

Thanks Peter for your excellent presentation on the "Answered Questions on ..." pages. The idea to put trails on each page (Home, back, and forward) was grand. The idea for a table of contents for each page was also very appropriate.

The same goes for the excellent presentation on the Answered Questions Index Page.

This is very professional work which makes those pages a pleasure to read. Thanks again!


Robert Abitbol

Hi again Peter,

I am not a programmer, I'm more a designer, an architect and I modestly don't have the required knowledge to identify the subject, to put the title to any of the answered questions without a little help from my friends (as the Beatles songs went) :-).

But I surely can move them on the right page and create new Answered Questions on: pages!

Can you please write the title and the category of the 10 questions I have moved to Answered Questions to be classified. From the info you'll give me, I'll move them to the appropriate Answered Questions on: pages afterwards.

If on the other hand you feel like doing all the moving work by yourself, it's also fine by me. Just let me know.

Best regards.

-- Robert Abitbol

Peter Newman 30 October 2004: Thanks Robert. But I don't think I could handle doing it that eay. The problem is that each question and answer takes 2 or 3 minutes to do. And that's the time you need to read it, and try to figure out what's really being discussed, and what category it's to go in. Having decided on a category, I move it there. But then, where it goes on that page, and what title I'll give it, depends on where other related things on that page are, and what they're called.

So all the time's in the thinking - which is both before and after the few mouse clicks needed to physically move it. And whilst I might decide that it should go on a certain page, it's not till I actually get it there - and then look at the other questions/answers on the page - that I can really decide that that's definitely where it should go (and what it should be called). Obviously I can't do it all myself. But moving an individual question and answer is really an all or nothing thing, that one person's got to do - and you can't really sub-divide.

But you've been doing a great job with the other bits and pieces. And if I think of some other thing that you might be able to help out with, I'll let you know. Thanks, Peter.

Robert Abitbol OK! Sounds good! Just tell me and I'll be glad to help.

About the work to be done, there is no rush! I recommend you go slowly but surely: do 10 answers a day and that's 3650 a year! Slow but often is the way I've been working for many years and I hate myself for not starting sooner!

Now one of the best advantages of your system is that if you don't know where an information is located, you can "jump" from one table of contents to another using your trail system starting with the first "Answered Questions on:" page and right away you'll get your information (if it's there of course).

Your system is the proof that Wikis are not just a tool to create independent pages helter skelter without any hierarchy but it lends itself well to well-organized work.

It's a pleasure to see clear, well presented information.

I hope others will be inspired by your work, will follow and give you a hand.

Again, many thanks!


Robert Abitbol

Peter, the work you are doing is extremely useful and no matter which system will be chosen, your work will have proved to be useful.

Indeed! You are giving a title to a problem page and you are giving it a category. This information will be useful for all systems envisaged.

Very much like you're in a situation where you are working with people who are not yet certain what type of car they want to want to build. So in this case, you take care of the conception of the weels because no matter what they chose, they'll need wheels.

When Colin says you're creating a mess, you should not pay attention for he does not really know how systems work... He criticizes, he demolishes but not only does he suggest nothing in return but he is not even interested in working. He loves to argue and to criticize and he gives new meaning to the expression: "too many cooks spoil the broth". You'll find a lot of people like him on wikis and in real life. It takes all kinds of people to make a world! :-)

Colin does not realize that you are doing is very useful work but rest assured the rest of us know how useful your work is...

What is important at this stage is categorizing a question and giving it a title.

Keep it up!

Again thanks for your excellent input.


CMcC Some comments, since my name was mentioned:

  1. RA When Colin says you're creating a mess, you should not pay attention - So much for Feedback.
  2. RA for he does not really know how systems work ... and other silly personal slanders, should show you the kinds of tactic RA uses when people disagree with him for reason. Ask around, I'm sure others can provide evidence.
  3. RA Colin does not realize that you are doing is very useful work. More correctly: I do not believe your work is useful. I have given ample justification for this belief, to no avail.
  4. RA but rest assured the rest of us know how useful your work is - I've come to recognise this as a common motivating tactic of RA's. It is an appeal to some nebulous greater or future benefit which will accrue to those who get with the programme. You may decide that the never-quantifiable benefit is real, or you might decide that you are being played as a patsy.

Please don't edit anything below this line. It's stuff from Ask, and it shall be given. that's being transferred to the "Answered Questions On: Whatever" pages. Thanks. Peter Newman, 29 October 2004.



Category:

22-Oct-2003 I'm using tclkit to run tcl stuff on windows plattforms, but i can't open files under Windows XP. Win 2000 works fine, are there any known issues with Win XP, maybe concerning filepaths? Bernd

Vince -- no, there are no known problems on XP. You'll have to be much more precise about what your doing. Provide a short script (< 10 lines) which works on 2000 but fails on XP. This should be easy if you can't open files.

Well, a single line will do: "set FILE open test/file.txt r". This works fine on 2000 but fails to find the requested file on xp. The problem remains when i replace slash by backslash, i'd think both variants should work. There is nothing else in the script i used for my test, the script is wrapped for win using: "sdx wrap tclxp.exe -runtime tclkit-win32.upx.exe". -- Bernd

I'm really surprised now, because i can't even open a file in the same directory ("set FILE open file.txt r"). So it's not a slash, backslash problem. -- Bernd

Vince with any bug report, the error message you get is critical. Anyway, I suggest you report this on comp.lang.tcl or on sourceforge, not here.


Question on text widgets displaying large files moved to text.


Category:

18-Oct-2003 Hello! I have a question about Winico. I have installed the package and have trouble loading it. After copying the winico03.dll into the working directory, I enter the following: load winico03.dll

I get a cannot find library winico03.dll or one of its dependants. What would cause this and what do I do to overcome it? Thanking you in anticipation.


Category:

Broken Link??? Sep 30 - 2003

Hello.

I tried the following link that was on the wiki site (ftp://ftp.dcade.de/pub/ml/tcl/packages/tcl_messageBox10.zip ) but could not get through. Anyone have any luck as I would like to view this.

Thanks

Ep


Category:

Tcl Installation/Uninstallation Sep 30 - 2003

Hi all!

I easily compiled and installed the latest Tcl source code. I was needing it for compiling expect. Now I am done with my tasks, I have successfully uninstalled expect, but I found that there is NO make uninstall available for the Tcl code.

Does anybody know any way to uninstall Tcl source code, apart from searching by date and removing file by file!?

Your help is much appreciated!! Have fun, Oscar


Category:

Sep 29 - 2003

How can i use the options(-error,-sockname,-peername) of configure command of socket ? The main problem is, like -sockname option returns three elements so how can i store these values to use further?


Category:

Sep 25, 2003

I have a channel that I have opened as:

 set cid [ socket -server cfg $port ]

From time to time the client times out reading this channel. When that happens the data in the buffer (from a puts command) is no longer valid. I would like to throw it away. NOT flush it, which just sends it to the client the next time the client tries to do a read, but actually empty the buffer and throw the data away. How can I do this? Thank you in advance.


Category:

20-Sep-2003

I'm messing around with tk_setPalette I have a problem with the foreground being black on black or more precisely very dark blue this is only a problem with errors which I can't read unless I edit both libs: dialog.tcl and bgerror .tcl. I made the foreground red which is readable. I hate messing with the lib scripts though, is there a way I can do this from within the main script?


Category:

04/August/2003

   (Formerly 31/July/2003, with added details)

I am trying to analyze some hex numbers with odd size bit fields and was trying to write a tool to break up the bit fields. The problem is that I haven't been able to figure out how to enter hex numbers and have them not converted to decimal in the ENTRY field. It's hard to figure out if the rest of the code works when the display keeps changing to decimal on me. Thanks in advance!

Okay. I had vTCL write a GUI where I enter a number at the top which will be HEX in the final version. Then I have fields that allow entry of up to 16 bit-field sizes and a a display area for each field's value. The last element is a "doit" button. The code then figures out how many fields there are and for each field it uses shifts to eliminate all bits outside the current field with the field ending up in the low order bits so it can be displayed. Now that I have the basic GUI, I'll make all the other changes myself. Here's an example:

   Initial number is A5A5, divide it into a 5 bit field, a six bit field and a five bit field:

     15  14  13  12  11  10  9   8   7   6   5   4   3   2   1   0   <-- Bit number
   | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | <-- Bit Value
   -----------------------------------------------------------------
   | 1   0   1   0   1 | 0   1   0   1   0   1 | 0   1   0   1   0 | <-- Desired fields
           0x15                 0x15                   0xA           <-- Values of desired fields in HEX

The problem is the initial entry of the hex numbers. Here's my current entry command where I've tried to limit the input to hex digits, but it treats the entry as a decimal integer (I currently have to enter decimal to get it to take a number, so I had to increase the field size and chose 8):

     entry $base.ent61 \
         -background white -takefocus {} -textvariable RawHex -width 8 \
         -validate key -vcmd {expr {[string is xdigit %P] && [string length %P] < 8]}

FW: So does it treat the entry as a decimal integer, or actually convert it? You've said both.


Category:

Question (12 June 2003)

MAK I recently had a visually-impaired prospective customer, who uses a screen reader program called Jaws [L1 ] evaluating one of my products that uses Tcl/Tk for the GUI. I decided to try it myself to see how the GUI could be improved for such use. Not surprisingly there were some problems, mainly with some custom megawidgets that aren't really conducive to screen reader use, though many would be fairly simple to fix (such as allowing elements to take focus that currently don't). Some basic widgets/elements such as menus and text widgets seem to work okay, others like entry widgets don't, at least the way they're currently used. Some work partly: the text widget speaks when you select text, but for some reason my syntax highlighting causes only parts of the text (the non-highlighted parts) to be spoken.

Perhaps someone has experience writing screen-reader-friendly Tcl/Tk applications and could write a bit of a tutorial or tips page of some sort on developing Tcl/Tk applications that are compatible with screen readers? Thanks.

Note: I did see Speech Synthesis, or Talk to me Tcl but it seems like it might be better to make use of any features inherent in Tcl/Tk widgets to tie into Windows Accessibility features that a screen reader such as Jaws use. Some items work fine, so why not all?


Category:

Question (9 jun 2003) : I'm trying to compile a c++ dll library (under Windows 2000, using Dev-Cpp) that interfaces with tcl scripts. Even if I've linked the tcl83.lib and tk83.lib, and include tcl.h, I get the linking error: "undefined reference to _imp__Tcl_CreateInterp" and other similar. Same error if I try to compile a simple c/c++ program. The strangest thing is that, if I split the tcl functions in a testing procedure in the same file as the main it works. But as I use a different file for the procedure, the compiler gives the same linking error. Could anyone help me? Please write to: [email protected]



^^^^ Done/UN-Answered ^^^^


vvvv Not Done/Answered And UN-Answered vvvv



Category:

08/28/2003 - DOES WINDOW-MANAGER KNOW CONSOLE TOO?

Hi, does anybody know how I can place console-window on screen? Normally I use this for a toplevel-widget:

 wm geometry . "+$xpos+$ypos"

But for console I doesn't know how to handle it.

Franko - RS: The console runs its own child interpreter. This works for me (Win2k):

 console eval {wm geometry . +0+0}

mille grazie! (ital.)


Category:

Question (10 June 2003): Just to clarify the question below: I am doing a bind as follows (this follows the Russian encoding in TIM):

proc setupIndic {} { foreach {in} { a b bh bhr c th tr dh dhr k kh kr <etc>

                        hr c th tr dh dhr k kh kr <etc>''

} { bind Indic $in "keep_accounts %K; %W delete insert-[del_text $in [get_last]]]c insert ; %W insert insert [encode_key $in [get_last]]]; break"} }

Now, the proc 'keep_accounts' keeps a track of the keys pressed. The proc 'encode_key' must dynamically encode the character entered depending upon the context, i.e., it must look up the last character to do the encoding. I have made $last a global variable that is set from the proc 'keep_accounts'. However, I am seeing that the proc encode_key receives the value of $last only at start (at the time of bind) and never after. How do I make encode_key use the current value of $last?

If any further clarifications are required, I'll be glad to provide them. Thanks,AB - RS: Hm.. best put all binding code into a single proc that gets %K and %W as arguments. The brackets around del_text etc. will be evaluated too early - at definition time of the binding. I think you rather want them to happen at event time, so put them into the binding proc. Use global variables for maintaining state (like what the last keypress was).


Category:

Question (9 June 2003): I am planning to write an editor for Indic scripts (Devanagari, Bengali, Gujarati etc) using an English keyboard and so the code needs to encode the entered text. I am planning to build upon TIM (a tiny input manager). The TIM uses a simple lookup inside the foreach {in, out} loop for map the entered keystroke and the output which is displayed; however, here things are more complex and each keystroke has to be bound with a procedure that has to dynamically alter the glyphs to display depending upon the context. Can anyone suggest a way to do this? Thanks, AB -

RS: You want context glyph selection, and a simple Arabic renderer might give you ideas in that direction. I've also toyed a bit with Hindi, but one problem is that the Unicode does not include the ligature glyphs, so fonts (like MS Mangal) don't deliver them... But you might have better equipped fonts. Binding a keystroke to a procedure is very simply done; but the implementation of this proc will need a lot of linguistic knowledge.. Be assured it's possible, but I have no easy solution at hand.


Category:

Question (19 June 2003) SSA I have got a huge ASCI file generated by an application as a tracefile. Its size is 8.28GB! Now when I try to open this text file in tclsh using the open command with r(ead) permission, an error is generated.

 open "mp3frame.trc" "r"

The error generated is:

couldn't open "mp3frame.trc": Value too large to be stored in data type

Can anyone make head or tail of this and any workaround for the same.

schlenk If you use Tcl 8.3 this can happen, it does not use 64 bit file size pointers, so you cannot open files larger than 2GB, use Tcl 8.4.


Category

July 18, 2003 pdm

Extending Existing TCL-based Programs or Getting Other Interpreters

I would like to add my own commands, written in C, to a third-party program that uses TCL. I have read the books, tutorials, etc about Tcl_CreateCommand and know how to use it. It, however, needs a pointer/handler to the interpreter.

If the existing app does not supply me with a "get interpreter" or "add function" C function, can I get access to the interpreter that the program is using? It doesn't do me any good to define a new interpreter since the it won't be the one the user is interacting with.

Does this make sense? I can explain more if needed. Thanks in advance for any suggestions.

pdm It appears that the third-party program does have an "add function" C function. I am still curious about the original question. I had even considered the nasty hack of writing the pointer to a file in text format, reading it in my C code, converting it to a pointer, and using that pointer for the Tcl_CreateCommand function. Not a production-strength fix!

schlenk You could look for the load command and if it is provided just write a shared library (a tcl extension). See the sampleextension for an example.


Category

Question (10Jul2003)

When tearing off a menu (e.g. from Tk's menu widgets demo). The torn-off palette always appears at the upper-left corner of the desktop (under MacOS X and Windows at least), which is likely to be a long way away from where the actual 'tear off' action took place! Looking more closely at the underlying code, I actually can't see any way to make the torn-off menu appear in its most logical position: with its titlebar under the mouse pointer which was used to tear it off! The '-tearoffcommand' (which is the logical place) doesn't have any facility to discover the current mouse x,y coordinates. How can one do this in Tk?

Answer (from comp.lang.tcl):

menu ... -tearoffcommand mytearoff

proc mytearoff {w menu} {

    set x [expr {[winfo pointerx $menu] - [winfo width $menu]/2}]
    # Subtract 8 so the mouse is over the titlebar
    set y [expr {[winfo pointery $menu] - 8}]
    wm geometry $menu +$x+$y
    global tcl_platform
    switch -- $tcl_platform(platform) {
        "windows" {
            wm attributes $menu -toolwindow 1
        }
        default {
        }
    }
    # Put the focus on the torn-off palette, so the user can move it
    focus -force $menu

}

This still has the side-effect that the torn-off menu flashes in the top-left corner of the screen before being moved to the correct place. Not sure if much can be done about that...


Category

Question (08Jul2003) Been working with TK and have a basic question I can't find an answer for. How do I change the default graphic (currently the TCL feather image) in the window decoration to the left of the title text?

Thanks!

MAK - With version 8.3.3 and later you can use "wm iconbitmap $w -default /path/to/image" in your script to set the application-wide default icon, and this works on Windows. Earlier versions required the winico extension to change the icon via script on Windows or to recompile wish to include a different icon at build time.


Category

Question (07 July 2003) Hey everyone. I'm currently working with tcl 8.3.4. I have a pretty basic question about this language. Lets say I source a file by the name of foo.tcl. Is there any possible way to print out the current filename that you're working with? Thanks in advance!

schlenk Look up info script in your manuals. This gives you the file currently evaluated.

FW: The simplest way is to get the full path is, eg,

  puts "The full path to this script file is [info script]"

. Or to get just the file name, do:

  puts "The filename of this script file is [file tail [info script]]"

. This doesn't work with some cases like symlinks, but I doubt this will be an issue for you.


Category

Question (07 July 2003) Hey Guys, I am new here. I have an application written with tcl/tk8.3. I am displaying iwidget::dialog windows at various instances of my application. I have the modality on those popups setup to "global". So the idea is, if there is a popup the user will only be able to click on the dialog box. Unfortunately when the application receives other signals my popup gets pushed behind the main window and makes my appication totally useless. :(

My quesition is, how can I put all my popups inot a "Always on top" mode? I tried the "wm transient .dialogbox ." and it didn't help. Any suggestions please.

Thanks in advance.

FW: See Always on Top, perhaps?


Category

Question (6 jun 2003) : I have a Tcl/Tk script which I have used on flavours of redhat since V4.2. However when used on RedHat 9 all text labels appear double width (i.e. each character has a space - shown as a 'square') between it and the next character. I have searched everywhere for any reference to this problem on the web but no-one else seems to have encountered it. Can anyone tell me what the likely cause may be ? - paul / RS: You seem to be bitten by RedHat 9's incompatible Tk build, which makes Unicodes 4 bytes wide instead of two. You might rebuild Tcl/Tk with the original sources, or maybe get a prebuilt binary to replace the RH bugger.


Category:

Question (06/06/2003) if some one can help me with this question, i'll be very greatful. i want to write a program in tk . the program will make the graphical user interface to assist the novice to use unix command ln. the tk program must have atleast 10 options availaible as buttons. Options that are mutually exclusive must be grouped as radiobutton groups. On line help/explanation of each support option must be availaible to the user preffrably by double clicking (or other means) the button concerned.Default option if any should be pre selected. A start button will start executing the unix comand . Output from the unix command should be displayed on the tk text window. the unix command is ln. i 'll be very greatful if someone can solve this one for me. if anybody can't put the solution here can they e-mail it to me at [email protected] thnx.


Category:

Question (05/30/2003) Say i have 2 servers up and running, now as a cleint how can i get a choice to connect between the 2 servers, without prior knowledge about their address and port number?? Or simply said how do i get a list of the existing servers?? -- sudhi

DKF - There's no truly general solution to this (other than something disgusting like port-scanning!) though one cheap trick is to use a well-known hostname and port (e.g. insisting that the server runs on a machine with a known alias in your local DNS and on a predefined port.) Other than that, you're asking for a service registry, and this is indeed a component of all higher-level RPC systems...


Category:

Question (05/30/2003) Thanks for the continuous answers i'm getting.I'm able to login using the serial port connection and also execute process listing (ps -aef) on the remote solaris machine. As of now i manually type in the password, but i need to send the login name and password in the background and login. As was told i downloaded Expect and tried running the Expect commands on the TCL prompt but it says "Invalid Command". How do i integrate Expect commands inside the TCL script because i'm expected to complete this project work using TCL scripts and not anything else. Can Expect commands be embedded inside TCL script and if so how do i run it. Can't i do the above in TCL itself.

FW: Some very basic features are provided at expect in pure Tcl. Does that help?


Category:

Question (05/28/2003) Hey guys I am try to write a Tcl script that works both on Windows and Linux. All what I need is, when there is an event happens in my application I want to play a BEEP. I don't want to use SNACK because of the Hardware requirements. I am focused strictly towards the internal speakers. In order for me to test this, I wrote a script that calls the "bell" command. It works on Linux but not on Windows! Does anyone had the same problem before? Any info is really appreciated. Thanks!

kroc: bell is a Tk command. Try "puts \a" instead.


Category:

Question (05/26/2003) append var string isn't exactly parallel to lappend var list', in the first case you can combine a string of length x and a string of length y and get a string of length x+y, in the second case you can combine a list of length x and a list of length y and get a list of length x+1. What's a good way to get the list of length x+y? Best I can think of is foreach element $list {lappend var $element}, or eval lappend var $list

There is a slight mismatch and you have discovered the right answer to the problem. Another possible solution would be:

  set var [concat $var $list]

or (maybe faster):

  set var [concat [lindex [list $var [set var ""]] 0] $list]

Category:

Question (05/26/2003) My last posting was on the 05/15/2003 regarding the serial port. Thanks so much, in fact i had lost hope because i kept checking for replies everyday but could not find any. Today when i checked i found the answer and was overwhelmed. Actually my requirement is as follows. I need to login to a Solaris machine through a serial cable connection (com1) from a Windows computer. Then run process listing (ps -aef) on the Solaris machine, tail the output, parse them, get back the results and store it as a file back on the Windows machine. Please help. Thanks so much.

As told before expect is perfect tool for this, but Expect for Windows is a bit of unfinished, not everything works, for your task though it should be perfectly ok to use the unfinished port from david graveraux. If not you could use cygwin and it's expect binary for a unix environment on windows. For the details of the scripts you should read the book BOOK Exploring Expect or the expect webpages.


Category:

Question (05/16/2003) http and cookies: Similir to "An Http Robot in Tcl", I'm interested in creating a tcl script using the http package that allows me to log in a website that I subscribe to with username and password and get to the subscriber pages; following the example, I viewed the html source to find the form method is "post" and the form name strings of interest, so I used the lines below:

  set query [http::formatQuery UserName $user Password $passwd]
  set http [::http::geturl $url -query $query]

However, I believe the site is relying on cookies as well. What else do I need to do to handle the cookie requests within the script to get beyond the login screen and get to the pages I'm interested in getting to automatically? If it helps, the url looks something like this: www.website.com/Login/Login.aspx?reqpage=/sub/subfolder/page.htm Thanks!


Category:

Question (05/15/2003) I need to connect to a machine using the serial port, poll that machine at 5 minute intervals and be able to send traps. Thanks in Advance, Chacko.

Follow the links to the man pages from using a serial port, if you want to send SNMP traps you should take a look at Tnm/Scotty/TkInEd, for other automation tasks expect is The Best Tool.

MIB Smithy SDK also supports sending traps, though it may be overkill for your project.


Category:

Question (05/12/2003) Image Brightness and Contrast: Is there a quick way of adjusting an Tcl/Tk image's brightness and contrast levels. Currently I have a C funcion that does this by recalculating each image pixel based upon the brightness and contrast level, but to update the image display I need to pass back the entire image, which takes time. I am looking for a solution that is much quicker. Using XWindows/MOTIF I was able to do this by directly changing the colormap for the image, is there something similar for Tcl/Tk?? I have seen some things related to colormaps in Tcl/Tk, but there is very little written about them it seems. Thanks, Alan.


Category:

Question (05/12/2003) Hi, I'm looking for a function in Tcl/Tk such like atoi() in C or ord() in pascal. - RS: atoi() parses an integer from a string. Tcl parses integers from strings whenever it needs one, without you having to call a converter. ord() converts a single char to its ASCII integer, right? Then use scan with a %c format:

 set outint [scan $inchar %c]

Category:

Question (05/07/2003) I am trying to write a tcl/tk program for windows which is stand alone ie the user cannot escape out to windows, I have used the overridedirect to remove the controls but I am having problems with the famous CTL-ALT-DEL, does anyone know of a simple way to block/intercept/... from within tcl (registry) or an extension DLL or (last resort) in c/c++ to add a DLL. I'm using freewrap for the distribution and the option to pass on standalone can be activate from within the application. - RS: I'm afraid no user software can intercept Ctrl-Alt-Del - that's why it triggers the login, for instance. - JPT: Using the DLL extension, you can achieve what you want (on win95/98) with the following call:

  to disable CTRL-ALT-DEL: ::dll::call user32.dll SystemParametersInfoA v {i 97} {i 1} {i 1} {i 0}
  to re-enable it: ::dll::call user32.dll SystemParametersInfoA v {i 97} {i 0} {i 1} {i 0}

Category:

Question from amarnr concerning displaying text in a text widget moved to text.


Category:

Question (05/01/2003) I am a tcl/tk newbie, and would like to know how to control the positioning of windows on the terminal screen when they pop up. If I run the same wish script multiple times, I would like the windows to appear so that they are visible in their entirety, if possible. The current behavior is that they pop-up in a cascading fashion, each overlaying the previous ones. Thanks for any guidance you can offer.

Answer (05/01/2003) The initial placement of a program's window is in general a window manager issue. Many X Windows based window managers are quite smart in their layout while Windows is notoriously bad. That being said, a tcl/tk program can help in creating good layout. The key command is wm geometry which lets you place a window anywhere on the screen. The hard part is figuring out the best place to put it--only the window manager knows the placement of all the other windows.

But for the problem of running the same wish script multiple times then there are some clever solutions. One way is to use the send or dde command to have the programs talk w/ each other to figure out layout.

Another way is to always place the Nth instance of the script in a fixed location and spawn the ps command (or tlist on windows) to determine which instance you are.


Category:

Question (04/08/2003) Hey Guys, this site rocks! Now to my question..., I have an application written in ActiveTcl-8.3, I like to compile my tcl script into a binary. Is there a free version of the compiler available out there? I try to use procomp and it is looking for a license! Please help! Thanks! Answer (April 11, 2003) See How can I compile Tcl type scripts into binary code and Procomp.


Category:

Question: (4/08/03) I am a novice at Tcl. I would appreciate some suggestions for script to extract a single word (variable) from the body of an Email Webform. There are no keywords or other delimiters to use as a reference, because the text immediately before and after this variable is not constant. However, the word always appears as the first word on a specific line of text. Any suggestions would be most welcome. Thanks, David Dantes. [email protected]

FW: Do you have the data stored in a variable already? If so, let's assume it's the third line. It's as simple as this:

 regexp {^(.+?) .*$} [lindex [split $text &quot;\n"] 2] text word

will place the relevent text into the variable word.


Category:

Question: (4/07/03) Hi yall. I have tcl code that uses a command pipe to send commands to a daughter process. How can i send an interrupt signal (specifically Control-C) to the duaghter process? Would i use the command pipe at all? Thanks everyone.

DL: You would use the command pipe if it's a pty. If you're not using Expect, it almost certainly not a pty. In that case, just send a signal using kill (from C code) or TclX extension or exec kill on a UNIX box.


Category:

QUESTION: (07-Apr-03) Hi All, I am using Tcl_CreateInterp to create multiple tcl interpreters which dont need to communicate with eachother. It seems to work fine but is it ok to do this OR should I be using Tcl_CreateSlave etc? If so does any one have a piece of sample code? thanks a lot! -KG


Category:

Question : [4/02/03] (See Update below) Hi! I am trying to create a dynamic table which is basically many rows of iwidget::combobox. User should be able to add a new row to the end of the table with a pushbutton. The limit on the number of rows is limitless or a large number. This I can do, but when user is playing with one of the comboboxes, I need to know which one user is playing with. In other words, if user is picking the combobox on the second row, I need to know that it is the second row. Since the table is dynamic, I cannot have hardcoded row numbers to each combobox. If I send the row index to a procedure as a variable, like in the code below, the variable is constantly changed and the command always recieves the last row index. How can I get the row that the user is in? Thanks!

 proc addRow {} {
   global row_ix

   iwidgets::combobox $w_btch.table.prj_entry($row_ix) -command {thisRowClicked $row_ix}
   grid $w_btch.table.prj_entry($row_ix) -row $row_ix -column 1

   incr row_ix
 }

*** UPDATE *** [4/03/03] Somebody helped me fix this problem and wanted to share... Instead of defining the command arguments in braces, make a list as in;

 iwidgets::combobox $w_btch.table.prj_entry($row_ix) -command [list thisRowClicked $row_ix]

Thanks Jeff!

FW corrected the formatting in this question.


Category:

Question : [3/29/03] How do you prevent unix commands (e.g. clear, ls, rmdir etc) to trigger the eof and eeof status in the text entry box?? Plsease HELP!!!!


Category:

Question : [3/28/03] Hi. I'm running Tcl/Tk 8.4.2 on Win2000 and having some trouble changing background colors on menus. I can change background in all other widgets but for labels of cascade menus added to other menus like you see on a menubar. Is there a trick to this? I've even tried

   options *Menu.background white startupFile

upstream. Thanks, jtg [L2 ]

MGS [2003/03/30] Haven't tried this, to see if it answers your question, but your syntax above is incorrect. Try:

   option add *Menu.background white startupFile

In fact, on Windows, I think colors for all native Windows widgets are controlled by the Windows display properties. so you may not be able to change the colors at all from within tcl/tk.


Category:

Question : [3/27/03] Hi Is there any method to know the underlying OS from within a script. sudhi [L3 ]

See: tcl_platform


Category:

Question: Hi I am a tcl/tk dummy. I have created a simple tcl/tk based photo album. I like to make it look sexy with some cute backgrounds/canvas. Does tcl/tk support this feature? If so..., where should I be looking for information? Thank you folks!

FW: Depends on what you mean. You can put images in an application, or place buttons on an image, or use a canvas to create custom widgets or draw shapes... what sort of stuff do you need, exactly?

Bear in mind, the software industry is heading towards encouraging a consistent look-and-feel with other applications rather than flashiness, so my main goal in the decoration of an interface is usually to make it look familiar.

Hey Thanks for that reply. I was thinking about the common look and feel too! Say I wanna create a windows xp look and feel (hope its not too much for tcl/tk!). Or even something colourful like QT Front ends.

FW: Well, Tk looks averagely native on Windows XP (uses the correct scrollbars and such). It adapts to match the look and feel of the platform it's on to some extent. The colors on all the widgets are tuned to match the current platform and such, and the overall look is also maintained, but there still are a couple shortcomings you may want to consider. The buttons, for example, still aren't quite native in appearance (they look like ones from earlier versions of Windows), but you could simulate them by using the 'SystemButtonFace' color and building up a very approximate likeness using a canvas. However, the old-style buttons are fairly common in XP applications, so people don't really tend to even notice. Most widgets let you customize the background, foreground, and relief style (flat, groove, raised, ridge, solid, or sunken) - but any customized widgets beyond that have to be made with image and/or canvas-based simulations. I myself am making a custom look-and-feel application, and I intend to use images that swap with click events for the buttons.


Category:

Question: [3/22/03] I am responsible for maintaining a C++ application with a Tcl interpreter embedded in it. I need to modify the application to contain multiple Tcl interpreters, each running in a different thread. These interpreters need to be able to execute scripts concurrently. I also need to load a set of user-defined C extensions into each of these. I have compiled Tcl with the flag that enables threading, but I'm stumped as to how to proceed. I have tried creating threads in C++, but Tcl_DoOneEvent hangs/kills threads when I try to run it in two threads simultaneously. I replaced this with a C++ event loop for each thread, but then Tcl_Eval hangs/kills threads.

How do I create threads containing a Tcl interpreter that will wait for and process commands/scripts until told to terminate? Essentially, the process needs to behave as though it contains multiple instances of tclsh. This process run on a Unix platform.

Thanks!!


Category:

Question: Hi I am creating an application using Tcl/Tk. I like to disable the ability to exit out of the GUI by clicking on the "X" on the upper right hand corner. How do I do that? I am a dummy for this place as well as for Tcl/Tk. Any info is much appreciated. Thanks!!

Answer: See: Catching window managed events


Category:

Question: TCL at sonic speed? 11 Mar 2003 What about speeding TCL up a bit (read: lot)? TCL is slow compared to Perl, Python and even Ruby and the question ponders me what can be done to improve TCl's performance? Just wait for Parrot?

FW: You're just plain wrong. Look at the numbers [L4 ]. However, if you insist on speeding Tcl up (which if you sped it up much more would be making it generally faster than the aforementioned languages), there are a few ways. Some minor startup speed decreases can be attained by using one of the bundling packages which stores Tcl as bytecodes rather than source, avoiding compiling expense. You may also use the ICE Tcl "compiler," which really just translates Tcl to C source code using Tcl libraries to do much of the work. It results, as of its last release, in approximately 30% faster code. It's pretty old, though, 1998, and uses Tcl 8.0.


Category:

Question: Can one implement C unions in TCL? 12 Mar 2003 Basically my problem is that I need to read and write fixed length records but a requirement is that I can "somehow" associate field names with the fixed length record and manipulate those the data via those field names and write out the record. I can use binary scan/format happily enough, but it would be nice if I didn't have to "unpack - binary scan" or "unpack - binary format" after reads and before writes. Is there any hope for me?


Category:

Question: How handles file lock?

There are several processes which can access some file, say a.dat The rule is that only one process accesses a.dat at time. More detaily, if some process accesses it, others waits for unlocking.

So, I used "flock" in tclx.

Each process do : 1. give a.dat read-lock 2. reads data 3. write data 4. unlock read-lock

but, I have some problem.

First it didn't work "flock". see this source :

 set hFile [open aaa.log r]
 puts "hFile1 : open r"
 flock -read $hFile
 puts "hFile1 : lock "

 set hFile2 [open aaa.log r]
 puts "hFile2 : open r"
 puts "hFile2 : read - [gets $hFile2]"

 funlock $hFile
 puts "hFile1 : unlock "
 close $hFile2
 close $hFile

I expected Error at "set hFile2 [open aaa.log r]" since "flock -read $hFile". But, there is no error. What happended?

Seconds, althought flock works well, since flock have not filename as parameter but file-channel, I must open file first and lock it. If this happened, it is wrong but possible.

 process1 : set hFile [open filename r]
 process2 : set hFile [open filename r]
 process1 : flock -read $hFile
 process2 : flock -read $hFile
 process1 : read data
 process2 : read data

So, what I misunderstands? And how use file-lock so that only one process accesses some file?

Regards from Nams.

mailto:[email protected]