=sinister= Posted March 15, 2008 Share Posted March 15, 2008 (edited) 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 March 15, 2008 by =sinister= Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 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") EndIfIf 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 More sharing options...
=sinister= Posted March 15, 2008 Author Share Posted March 15, 2008 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 More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 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 WEndNo 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 More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 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 More sharing options...
=sinister= Posted March 15, 2008 Author Share Posted March 15, 2008 (edited) Well the thing is, SmOke, the If statement is inside the loop =\ --edit-- never mind, i'm dealing with TCP stuff =P Thank you for your help SmOke_N Edited March 15, 2008 by =sinister= Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 15, 2008 Moderators Share Posted March 15, 2008 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 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