StrategicX Posted May 4, 2009 Share Posted May 4, 2009 Hey guys,Wonderin if anyone knows how to stop a function from completing if an If--Then statement becomes true, Im having a problem with detecting one thing with an If--Then statment that calls a dif, function if the expression is true, But after that function is done, the one called before it finishes and ruins things, since its wayyy out of order. Thanks guys,p.s Im pretty sure thats called 'Break' in C++ but in autoit, break is comething totally different.... *WoW Dev Projects: AFK Tele Bot development journalSimple Player Pointer Scanner + Z-Teleport*My Projects: coming soon.Check out my WoW Dev wiki for patch 3.0.9!http://www.wowdev.wikidot.com Link to comment Share on other sites More sharing options...
Authenticity Posted May 4, 2009 Share Posted May 4, 2009 break's AutoIt counterpart is ExitLoop. If you want to exit or return from a function just use the Return keyword. Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 4, 2009 Share Posted May 4, 2009 put it in a loop? $i=0 do if then else $i=1 this() endif until $i=1 iseem to have troubles understanding what your saying [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
Khab Posted May 4, 2009 Share Posted May 4, 2009 (edited) 'Break' in C++ only terminates a loop (While, If, etc) not a function. In AutoIt, ExitLoop does the same thing. There are a number of ways to achieve what you what, but I can't think of any particularly elegant ways to do it. One obvious way would be a flag and contain the remainder of the function in an If loop so that once the sub-function executes, the remainder of the primary function does not. $keepgoing = true Func 1 Do some stuff Func2() if $keepgoing then Do some more stuff endif endfunc func 2 Do some stuff $keepgoing = false endfunc Edit; Ha! Good thinking Authenticity! I should've thought of that option lol Edited May 4, 2009 by Khab Link to comment Share on other sites More sharing options...
gfunk999 Posted May 4, 2009 Share Posted May 4, 2009 This is how I do it, not sure if that's what you're looking for. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $loop = 0 $BreakLoop = GUICreate("Break Loop", 218, 101, 193, 125) $Status = GUICtrlCreateLabel("Loop : ", 24, 10, 75, 25, 0) $GO = GUICtrlCreateButton("GO", 24, 48, 65, 25, 0) $Cancel = GUICtrlCreateButton("Cancel", 104, 48, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GO loop() EndSwitch WEnd Func loop() While 1 GUICtrlSetData($Status, "Loop in Progress: " & $loop) $nMsg = GUIGetMsg() If $nMsg = $Cancel Then $Abort = MsgBox(36, "Cancel?", "Are you sure you want to cancel?") If $Abort = 6 Then ExitLoop Return EndIf EndIf $loop = $loop + 1 WEnd EndFunc ;loop Hey guys, Wonderin if anyone knows how to stop a function from completing if an If--Then statement becomes true, Im having a problem with detecting one thing with an If--Then statment that calls a dif, function if the expression is true, But after that function is done, the one called before it finishes and ruins things, since its wayyy out of order. Thanks guys, p.s Im pretty sure thats called 'Break' in C++ but in autoit, break is comething totally different.... Link to comment Share on other sites More sharing options...
StrategicX Posted May 4, 2009 Author Share Posted May 4, 2009 Thanks guys! Was right in front of me *WoW Dev Projects: AFK Tele Bot development journalSimple Player Pointer Scanner + Z-Teleport*My Projects: coming soon.Check out my WoW Dev wiki for patch 3.0.9!http://www.wowdev.wikidot.com Link to comment Share on other sites More sharing options...
ihackbr Posted May 17, 2009 Share Posted May 17, 2009 #gfunk999 I got a problem to exit from a loop with a SLEEP inside it. Im gonna use your code as an exemple. I click on CANCEL to ExitLoop, but it doesnt work. expandcollapse popup#include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Local $loop = 0 $BreakLoop = GUICreate("Break Loop", 218, 101, 193, 125) $Status = GUICtrlCreateLabel("Loop : ", 24, 10, 75, 25, 0) $GO = GUICtrlCreateButton("GO", 24, 48, 65, 25, 0) $Cancel = GUICtrlCreateButton("Cancel", 104, 48, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $GO loop() EndSwitch WEnd Func loop() While 1 GUICtrlSetData($Status, "Loop in Progress: " & $loop) $nMsg = GUIGetMsg() If $nMsg = $Cancel Then $Abort = MsgBox(36, "Cancel?", "Are you sure you want to cancel?") If $Abort = 6 Then ExitLoop Return EndIf Else Sleep(500) $loop = $loop + 1 Sleep(500) EndIf WEnd EndFunc ;loop Any idea? 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