Juggernaut 0 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 Share this post Link to post Share on other sites
hannes08 39 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] Share this post Link to post Share on other sites
Juggernaut 0 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 Share this post Link to post Share on other sites
hannes08 39 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] Share this post Link to post Share on other sites