Prev: Another suggestion/asking: background for canvas
Next: Simple Hack To Get $2000 To Your PayPal Account
From: Aric Bills on 13 Jul 2010 20:26 Presumably you want to adjust ditlen every time you set wpmpercent, so I'd include it in proc setwpmpercent. You also need to make sure you create these variables before your program first uses them. One way to do that would be to include a call to setwpmpercent in your initialization code.
From: Bob on 13 Jul 2010 21:51 Well....thanks for all the help, but no matter what I try, the variable dit simply can't be found when I try to use it in the setwpmpercent proc. It would appear that what I am trying to do, can't be done in tcl. I have written the same program in vb.net and Forth, so I guess I'll have to be content with them. Thanks again "Aric Bills" <aric.bills(a)gmail.com> wrote in message news:2b4bacff-a548-41b5-8684-b61fdf8ddeef(a)d37g2000yqm.googlegroups.com... > Presumably you want to adjust ditlen every time you set wpmpercent, so > I'd include it in proc setwpmpercent. You also need to make sure you > create these variables before your program first uses them. One way > to do that would be to include a call to setwpmpercent in your > initialization code.
From: Aric Bills on 13 Jul 2010 23:29 On Jul 13, 7:51 pm, "Bob" <kava...(a)noga.com> wrote: > Well....thanks for all the help, but no matter what I try, the variable dit > simply can't be found when I try to use it in the setwpmpercent proc. It > would appear that what I am trying to do, can't be done in tcl. I have > written the same program in vb.net and Forth, so I guess I'll have to be > content with them. > > Thanks again Bob, don't give up on Tcl just yet. I guarantee that what you are trying to do can be done in Tcl. If you're willing to post your code (or e-mail it to me privately, if you'd rather), I or others can help you indentify the bug. Without seeing the code, my guess is you want setwpmpercent to look something like this: proc setwpmpercent {num} { global wpmpercent dit ditlen set wpmpercent [expr {$num * 0.01}] set ditlen [expr {$dit*$wpmpercent}] } taking care that dit is initialized before the first time this proc is called.
From: Uwe Klein on 14 Jul 2010 05:38 Bob wrote: > Well....thanks for all the help, but no matter what I try, the variable dit > simply can't be found when I try to use it in the setwpmpercent proc. It > would appear that what I am trying to do, can't be done in tcl. Phrrrrrt. > I have > written the same program in vb.net and Forth, so I guess I'll have to be > content with them. D�nnbrettbohrer ;-) if you have a compound set of values you want to adjust on any change in a set of parameters use trace: proc MYupdate {var elem op} { puts stderr "trace activated by $var op: $op" set ::ParamA [ expr $::dit * ($::dat / $::foo) ] set ::ParamB [ expr $::dit / ($::dat * $::foo) ] set ::ParamC [ expr $::foo * ($::dit / $::dat) ] } scale .scdit -from .. -to .. -resolution .. -variable ::dit scale .scdat -from .. -to .. -resolution .. -variable ::dat scale .scfoo -from .. -to .. -resolution .. -variable ::foo pack .scdit .scdat .scfoo label .ldit -textvariable ::dit label .ldat -textvariable ::dat label .lfoo -textvariable ::foo label .parama -textvariable ::ParamA label .paramb -textvariable ::ParamB label .paramc -textvariable ::ParamC pack .ldit .ldat .lfoo .parama .paramb .paramc trace add variable ::dit write MYupdate trace add variable ::dat write MYupdate trace add variable ::foo write MYupdate #end you can find a working example in http://wiki.tcl.tk/15000 "vector expr" uwe
From: Bob on 14 Jul 2010 13:36 Ok, you certainly have more patience than I do. ;) ;) Here is the last iteration of many that I have tried. As I said, I am pretty much chasing my tail at this point, so this may not be the code that came closest to working. It is also stripped down to the point to just deal with these variable issues I have been having. (BTW, is there any way to just make a variable visible >from anywhere< >to anywhere< in the code? The program I have in mind is not going to be so complex as to have to protect variables. ############################################################################# proc wpmcalc {wpm} { set wpmper [expr {($wpm*.01)}] } proc init {} { global dit dah space wpm ditlen wpmper } init scale .dit -orient horizontal -label dit -variable dit scale .dah -orient horizontal -label dah -variable dah scale .space -orient horizontal -label space -variable space scale .wpm -orient horizontal -label wpm -from 80 -to 100 -variable wpm -command wpmcalc pack .dit pack .dah pack .space pack .wpm set ditlen [expr {int($dit*$wpmper)}] ############################################################################## When all is said and done, I want 4 scale bars: One that will control the length of a dit. (call it dit) One that will control the length of a dah (call it dah) One that will control the length of a space between the other two elements. (call it space) One that will provide a value (0.8 to 1) that will be multiplied with each of the other values, so as to increase or decrease all of them by the same relative amount. (call it wpm or more accurately "speed") (A related issue....this is where the 'wpm*0.01' code comes in....I also struggled with how to make a scale bar go from 0.8 to 1.0, so I gave up and went from 80 to 100). Then after converting each value to an integer (my original can-O-worms before everything else gave me fits), I'll use each as an argument to the 'after' command to control the timing of driving RTS high and low via the "wincom" dll I found on a tcl site. The RTS line will key/unkey a transmitter. I have a couple of books on tcl/tk, but they have not been of much help with this particular problem. I have others on the way, but first I'll need a good stiff drink. ;) Bob Bob, don't give up on Tcl just yet. I guarantee that what you are trying to do can be done in Tcl. If you're willing to post your code (or e-mail it to me privately, if you'd rather), I or others can help you indentify the bug. Without seeing the code, my guess is you want setwpmpercent to look something like this: proc setwpmpercent {num} { global wpmpercent dit ditlen set wpmpercent [expr {$num * 0.01}] set ditlen [expr {$dit*$wpmpercent}] } taking care that dit is initialized before the first time this proc is called.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Another suggestion/asking: background for canvas Next: Simple Hack To Get $2000 To Your PayPal Account |