Jump to content

Pausing only a portion of the script?


Delta01
 Share

Recommended Posts

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 advance

Func 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
        EndFunc

The above script is just one of the seven I have. All are fundamentally the same though.

Link to comment
Share on other sites

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

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!

My-Colors.jpg

cuniform2.gif

Link to comment
Share on other sites

... 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)

NEWHeader1.png

Link to comment
Share on other sites

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...