Delta01 Posted November 8, 2007 Share Posted November 8, 2007 Hi,I'm making a script which involves countdowns. There are 7 countdowns in the script, all of which will have different values and start at different times.I need to know how to pause only one countdown, not stop completely, I need to be able to resume it with it having the same time.The part of my script concerning the countdown is posted below. Thanks in advanceFunc Timer1() $iTimeToGo = $number1 - Int(TimerDiff($timer)) _TicksToTime($iTimeToGo, $Hour, $Mins, $Secs) ConsoleWrite($timer & @CRLF) ConsoleWrite(TimerDiff($timer) & @CRLF) Local $sTime = $Time $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Taxi Script", "", "Static1", $Time) If $iTimeToGo <= 0 then ControlSetText("Taxi Script", "", "Static1", "00:00:00") If $iTimeToGo <= 0 Then $bRunTimer1 = 0 Endif EndFuncThe above script is just one of the seven I have. All are fundamentally the same though. Link to comment Share on other sites More sharing options...
Fossil Rock Posted November 8, 2007 Share Posted November 8, 2007 Try setting a flag whenever you want to stop or start it. $flag = 0; OFF or Paused $flag = 1; ON Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Delta01 Posted November 9, 2007 Author Share Posted November 9, 2007 Try setting a flag whenever you want to stop or start it. $flag = 0; OFF or Paused $flag = 1; ONoÝ÷ Ûú®¢×¶¸vØZ´]¡ë'ßÛij붢éív'¶éZmé]¡ë'ßÛn¥Öy»¶g«ç©±Ê.اl¡×¢±«¢+ÙÕ¹Q¥µÈÄ ¤(%%ÀÌØíAÕÍôÀQ¡¸($$ÀÌØí!äôÈ(%±Í¥ÀÌØíAÕÍôÄÑ¡¸(ÀÌØí¥Q¥µQ½¼ôÀÌØí¹ÕµÈÄ´%¹Ð¡Q¥µÉ¥ ÀÌØíÑ¥µÈ¤¤(}Q¥ÍQ½Q¥µ ÀÌØí¥Q¥µQ½¼°ÀÌØí!½ÕÈ°ÀÌØí5¥¹Ì°ÀÌØíM̤( ½¹Í½±]É¥Ñ ÀÌØíÑ¥µÈµÀì I1¤( ½¹Í½±]ɥѡQ¥µÉ¥ ÀÌØíÑ¥µÈ¤µÀì I1¤(1½°ÀÌØíÍQ¥µôÀÌØíQ¥µ(ÀÌØíQ¥µôMÑÉ¥¹½ÉµÐ ÅÕ½ÐìÀɤèÀɤèÀɤÅÕ½Ðì°ÀÌØí!½ÕÈ°ÀÌØí5¥¹Ì°ÀÌØíM̤(%ÀÌØíÍQ¥µ±ÐìÐìÀÌØíQ¥µQ¡¸ ½¹Ñɽ±MÑQáÐ ÅÕ½ÐíQá¤MÉ¥ÁÐÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíMÑÑ¥ÄÅÕ½Ðì°ÀÌØíQ¥µ¤(%%ÀÌØí¥Q¥µQ½¼±ÐìôÀÑ¡¸(% ½¹Ñɽ±MÑQáÐ ÅÕ½ÐíQá¤MÉ¥ÁÐÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐíMÑÑ¥ÄÅÕ½Ðì°ÅÕ½ÐìÀÀèÀÀèÀÀÅÕ½Ðì¤(%%ÀÌØí¥Q¥µQ½¼±ÐìôÀQ¡¸ÀÌØíIÕ¹Q¥µÈÄôÀ($%¹¥($%¹¥($%¹Õ¹ Link to comment Share on other sites More sharing options...
Delta01 Posted November 9, 2007 Author Share Posted November 9, 2007 Bump Link to comment Share on other sites More sharing options...
Fossil Rock Posted November 9, 2007 Share Posted November 9, 2007 Ok, I thought you might understand how to properly use a flag .... my mistake Try a Select...Case statement ... (it's still a flag btw) While 1 Case = $Paused = 0 continue counter Case = $Paused = 1 pause counter wend I'll see if I can write a better example.... Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
Valuater Posted November 9, 2007 Share Posted November 9, 2007 ... The label doesn't update but the timer keeps counting. Maybe... as an idea Dim $iTimeHold Func Timer1() If $Paused = 0 Then If $Hey <> 2 Then $iTimeHold = ($number1 - Int(TimerDiff($timer))) + ($iTimeHold) $Hey = 2 EndIf ElseIf $Paused = 1 Then If $Hey <> 1 Then $timer = TimerInit() $Hey = 1 EndIf $iTimeToGo = ($number1 - Int(TimerDiff($timer))) + ($iTimeHold) ;...... *** not tested 8) Link to comment Share on other sites More sharing options...
Delta01 Posted November 10, 2007 Author Share Posted November 10, 2007 Ok, I thought you might understand how to properly use a flag .... my mistake Try a Select...Case statement ... (it's still a flag btw) While 1 Case = $Paused = 0 continue counter Case = $Paused = 1 pause counter wend I'll see if I can write a better example.... Sorry for being a noob. But, I don't understand. Link to comment Share on other sites More sharing options...
flyingboz Posted November 10, 2007 Share Posted November 10, 2007 Sorry for being a noob. But, I don't understand.you've got a counter of some sort -- since you don't provide code, nobody can tell exactly how to help you. The generic answer, as you have already been told, is to (1) use a variable as a flag to decide whether or not to decrement your counter. Lots of ways to skin the cat, but the nature of your question, and your response to it, indicate that you likely are going to need to redesign your counting logic.For example, if you're trying to base your counters off of the Timer() functions or the system time, you'll also need to store the times at which you paused a counter so you can do the math to properly keep the timers in sync.The good news is that what you want to do is possible, you just need to learn enough to understand the answers to the questions you're trying to ask. Reading the help file before you post... Not only will it make you look smarter, it will make you smarter. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now