Jump to content

timer help


Recommended Posts

If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf 

If TimerDiff($Start_Time) >= $Time_to_Wait And $QueStart = 1 Then
    Sleep(50)
    $Send = TCPSend($MainSocket, "/StartGlide" & @CRLF)
    Sleep(50)
    $Recv = TCPRecv($MainSocket, 553)
    Sleep(50)
        SetLog("Glider was stopped, started again!")
    _ResetTimer()
    $QueStart = 0
EndIf

I want my code to start the timer when the variable $recv has "Mode: None" in it, but it won't work. Whenever the variable $Time_to_Wait is above 0, it won't start the timer.

Edited by =sinister=
Link to comment
Share on other sites

  • Moderators

If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf 

If TimerDiff($Start_Time) >= $Time_to_Wait And $QueStart = 1 Then
    Sleep(50)
    $Send = TCPSend($MainSocket, "/StartGlide" & @CRLF)
    Sleep(50)
    $Recv = TCPRecv($MainSocket, 553)
    Sleep(50)
        SetLog("Glider was stopped, started again!")
    _ResetTimer()
    $QueStart = 0
EndIf

I want my code to start the timer when the variable $recv has "Mode: None" in it, but it won't work. Whenever the variable $Time_to_Wait is above 0, it won't start the timer.

Are we to guess what the real issue is?
$Recv = "abcmode: noneabcde"
$Time_to_Wait = 0
If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf

If TimerDiff($Start_Time) >= $Time_to_Wait And $QueStart = 1 Then
    MsgBox(0, 0, "here")
EndIf
If this works, then your code will work if those to conditions are true.

So the moral of the story you ask??? .... Either timerdiff is less than time to wait, or $Recv doesn't contain "Mode: None"

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

But SmOke_N,

as I said, it works when $Time_to_Wait = 0, but anything great it will not work.

$Recv = "abcmode: noneabcde"
$Time_to_Wait = 5000
While 1
If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf

If TimerDiff($Start_Time) >= $Time_to_Wait And $QueStart = 1 Then
    MsgBox(0, 0, "here")
EndIf
WEnd
Link to comment
Share on other sites

  • Moderators

But SmOke_N,

as I said, it works when $Time_to_Wait = 0, but anything great it will not work.

$Recv = "abcmode: noneabcde"
$Time_to_Wait = 5000
While 1
If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf

If TimerDiff($Start_Time) >= $Time_to_Wait And $QueStart = 1 Then
    MsgBox(0, 0, "here")
EndIf
WEnd
No kidding... because as I said, timer diff is LESS THAN Time to wait. Your condition states: If Timer Diff is Equal to Or Greater Than

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

What do you know :)

$Recv = "abcmode: noneabcde"
$Time_to_Wait = 5000
If StringInStr($Recv, "Mode: None") Then
    $Start_Time = TimerInit()
    $QueStart = 1
EndIf
While 1
    $sDiff = TimerDiff($Start_Time)
    ToolTip("Milliseconds: " & $sDiff, 0, 0)
    If $sDiff >= $Time_to_Wait And $QueStart = 1 Then
        MsgBox(0, 0, "here")
        ExitLoop
    EndIf
    Sleep(100)
WEnd

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

Well the thing is, SmOke, the If statement is inside the loop =\

Look, you are not seeing the obvious.

Provide a better example if you don't understand, because I've explained why exactly it won't work.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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