Jump to content
Sign in to follow this  
Regency

Using 1 while statement for 2 options

Recommended Posts

Regency

Ok, so i have a timer sentance that works perfectly, but now i need it to check for a second time within the first check. What should i edit it to make it wait for an hour and 30 min.

Local $begin = ''
Local $dif = 0

    While 2
        Sleep(10)
        $dif = Int(TimerDiff($begin) / 1000)
        If $dif >= (.5 * 60) Then
            MyFunction2()
            $begin = TimerInit()
        EndIf
    WEnd

How would i edit this to make it wait for also an hour and thirty min, while still watching for the (.5 * 60)?

Share this post


Link to post
Share on other sites
zorphnog

You would need two timers since your $dif >= (.5 * 60) expression is resetting the $begin timer. Something like:

$timer1 = TimerInit()
$timer2 = $timer1
While 1
    Sleep(10)
    $dif1 = Int(TimerDiff($timer1) / 1000)
    If $dif >= (.5 * 60) Then
        MyFunction2()
        $timer1 = TimerInit()
    EndIf
    $dif2 = Int(TimerDiff($timer1) / 1000)
    If $dif2 >= 5400 Then ;5400 secs = 1 1/2 hour
        DoSomething()
        $timer2 = TimerInit()
    EndIf
WEnd

Share this post


Link to post
Share on other sites
PsaltyDS

You would need two timers since your $dif >= (.5 * 60) expression is resetting the $begin timer. Something like:

$timer1 = TimerInit()
$timer2 = $timer1
While 1
    Sleep(10)
    $dif1 = Int(TimerDiff($timer1) / 1000)
    If $dif >= (.5 * 60) Then
        MyFunction2()
        $timer1 = TimerInit()
    EndIf
    $dif2 = Int(TimerDiff($timer1) / 1000)
    If $dif2 >= 5400 Then;5400 secs = 1 1/2 hour
        DoSomething()
        $timer2 = TimerInit()
    EndIf
WEnd
Good solution, but that second TimerDiff() needs to use $timer2 vice $timer1.

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.