Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Interrupting a procedure
I have a procedure that flashes a button and updates the button text at 1
sec intervals. I'd like to be able to interrupt and end this proccedure from
another procedure. How can I do this?

Thanks,
Phil

proc DoSMTimer {} {
proc toggle {v} {uplevel [concat set $v \[expr \[set $v\] ^ 1\]]}
proc Sleep {time} {after $time set end 1; vwait end}

set TogBit 0
for {set i $::SMTime} {$i >= 0} {incr i -1} {
if {[set TogBit [toggle TogBit]]} {set color #33ffff} else {set
color #3333ff}
.row5.spell configure -text "SpellMode in $i seconds" -background
$color
Sleep 1000
}
.row5.spell configure -text "Spell" -background #33ffff
}



Report this thread to moderator Post Follow-up to this message
Old Post
Phil Biehl
12-23-04 02:14 AM


Re: Interrupting a procedure
Phil Biehl wrote:
> I have a procedure that flashes a button and updates the button text at 1
> sec intervals. I'd like to be able to interrupt and end this proccedure fr
om
> another procedure. How can I do this?
>
> Thanks,
> Phil
>
> proc DoSMTimer {} {
>     proc toggle {v} {uplevel [concat set $v \[expr \[set $v\] ^ 1\]]}
>     proc Sleep {time} {after $time set end 1; vwait end}
>
>     set TogBit 0
>     for {set i $::SMTime} {$i >= 0} {incr i -1} {
>         if {[set TogBit [toggle TogBit]]} {set color #33ffff} else {set
> color #3333ff}
>         .row5.spell configure -text "SpellMode in $i seconds" -background
> $color
>         Sleep 1000
>     }
>     .row5.spell configure -text "Spell" -background #33ffff
> }
>
>
I think you are going about this the Wrong Way(R)..

You should create a proc to do the toggle functionality you want
then call it as a timer event. The following shows a simple
example...


proc DoDisplayToggle { } {
global runcount
global timerid

puts "Timer runcount = $runcount"

incr runcount
if { $runcount < 5 } {
set timerid [ after 1000 DoDisplayToggle ]
}
}

proc StartTimer { } {
global runcount
global timerid

# Start toggle timer
set runcount 0

set timerid [ after 1000 DoDisplayToggle ]
}

proc StopTimer { } {
global timerid

after cancel $timerid
}

Report this thread to moderator Post Follow-up to this message
Old Post
Quokka
12-23-04 09:11 AM


Re: Interrupting a procedure
Thanks Quokka! That worked perfectly. You read my mind and gave me just what
I needed!

Happy Holidaze,
Phil


"Quokka" <NoSpam@iinet.net.au> wrote in message
news:41CA1B5A.6090903@iinet.net.au...
> Phil Biehl wrote: 
> I think you are going about this the Wrong Way(R)..
>
> You should create a proc to do the toggle functionality you want
> then call it as a timer event. The following shows a simple
> example...
>
>
> proc DoDisplayToggle { } {
> global runcount
> global timerid
>
> puts "Timer runcount = $runcount"
>
> incr runcount
> if { $runcount < 5 } {
> set timerid [ after 1000 DoDisplayToggle ]
> }
> }
>
> proc StartTimer { } {
> global runcount
> global timerid
>
> # Start toggle timer
> set runcount 0
>
> set timerid [ after 1000 DoDisplayToggle ]
> }
>
> proc StopTimer { } {
> global timerid
>
> after cancel $timerid
> }



Report this thread to moderator Post Follow-up to this message
Old Post
Phil Biehl
12-23-04 09:08 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Tcl archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:57 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.