Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

counter

Status
Not open for further replies.

sl1200mk2

Technical User
Jun 7, 2005
39
FR
hi all

can anybody post a counter proc exemple

i would like the counter take the "count result" value as the initial value for a next count.
for exemple

count to 10 in 100ms:
0 1 2 .... 10

count to 60 in 200 ms
10 11 ...... 60

count to 5 in 50 ms
60 59 58 ..... 6 5

count to 23 in 150 ms
5 6 ..... 22 23
etc......

many thanks
nico
 
i got it approximatively
here's the code

set counting {}
set tempo {}


pack [spinbox .counting -textvariable lavalu -from 0 -to 512 -increment 10 -width 5 -command {lset counting $lavalu} ] -side left
bind .counting <Return> {set counting $lavalu ; puts $counting}

pack [spinbox .tempo -textvariable tempo -from 0 -to 512 -increment 10 -width 5 -command {lset tempo $tempo} ] -side left
bind .tempo <Return> {focus -force .}

pack [ button .go -text "go" -command {countdown2 $counting $tempo}] -side left

pack [label .counter -font {Helvetica 72} -width 3 -textvariable count] -side bottom

set result {0}

proc countdown2 {cnt temp} {
global result
set ::count $result
if {$cnt < $result} {
incr result -1
after $temp [list countdown2 $cnt $temp]
} elseif {$cnt > $result} {
incr result +1
after $temp [list countdown2 $cnt $temp]
}
if {$result == $cnt } {
lset result $cnt
return
}
}


how can i improve it?
++
nico
 
Status
Not open for further replies.

Similar threads

Replies
1
Views
37

Part and Inventory Search

Sponsor

Back
Top