Juggernaut Posted July 3, 2012 Share Posted July 3, 2012 So for some reason (ive tried a few ways) my loop won't stop. Here is my code: While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn_start $user_input = GuiCtrlRead($txt_user) $active = true StartTimer() Case $msg = $btn_stop $active = false Case $msg = $btn_info MsgBox(0, "Information", "test") EndSelect WEnd GUIDelete() EndFunc Func StartTimer() While 1 if $active = True Then ;do stuff Else ;STOP LOOP? - $active defined above should stop it? EndIf WEnd EndFunc If anyone has some ideas, it would be appreciated **sorry about the formatting of the code, for some reason it did that when i pasted it onto here Link to comment Share on other sites More sharing options...
hannes08 Posted July 3, 2012 Share Posted July 3, 2012 Juggernaut, $active does not stop your endless loop (while 1). just add an ExitLoop in the else section of your StartTimer() function. Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] Link to comment Share on other sites More sharing options...
Juggernaut Posted July 3, 2012 Author Share Posted July 3, 2012 Yeah I just tried using ExitLoop, but for some reason it doesn't do anything besides 'freezing' my program. I can edit the text control, but using the buttons, or trying to close it doesn't work. While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $btn_start $user_input = GuiCtrlRead($txt_user) if $user_input = "" Then MsgBox(0, "Error", "Invalid") Else $active = true Start() EndIf Case $msg = $btn_stop $active = false Case $msg = $btn_info MsgBox(0, "Information", "test") EndSelect WEnd GUIDelete() EndFunc Func Start() While 1 if $active = true Then ;do stuff Else ExitLoop EndIf WEnd EndFunc Func quit() Exit EndFunc Link to comment Share on other sites More sharing options...
hannes08 Posted July 3, 2012 Share Posted July 3, 2012 (edited) Juggernaut, this should work... While 1 if $active = true Then ;do stuff ;Set $avtive to false ; OR cast an ExitLoop here Else ExitLoop EndIf WEnd Btw. you can use [ autoit] and [ /autoit] tags to enclose your code. Edited July 3, 2012 by hannes08 Regards,Hannes[spoiler]If you can't convince them, confuse them![/spoiler] 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