atomman Posted December 24, 2007 Share Posted December 24, 2007 Normally if i want to abort a Case, i'd just use ContinueLoop. How would you do this if ContinueLoop is in a Func outside the loop? It doesn't have to be ContinueLoop that is used, i just need to abort the Case. Link to comment Share on other sites More sharing options...
rasim Posted December 24, 2007 Share Posted December 24, 2007 ExitLoop([level]) Return Link to comment Share on other sites More sharing options...
Nutster Posted December 24, 2007 Share Posted December 24, 2007 (edited) Normally if i want to abort a Case, i'd just use ContinueLoop. How would you do this if ContinueLoop is in a Func outside the loop?It doesn't have to be ContinueLoop that is used, i just need to abort the Case.Can you give more detail of how you want to do this? A small example script would be helpful. There are several ways of addressing this, depending on the details. A function called from within a loop can not use ContinueLoop or ExitLoop inside the function, unless it has its own loop. Generally I would check the return value or @Error from the UDF call and then call ContinueLoop or ExitLoop accordingly. Again more details would be helpful. Edited December 24, 2007 by Nutster David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
atomman Posted December 24, 2007 Author Share Posted December 24, 2007 Here ye go... While 1 $Msg = GUIGetMsg() Switch $Msg Case $Button_HlLnk _GoApp(); switch to App ; remainder of Case EndSwitch Func _GoApp() If $Var = 1 Then MsgBox(262144, "Error!", "App not found!") ; ### substitute for ContinueLoop goes here ### Else WinActivate($App) WinWaitActive($App) EndIf EndFunc Link to comment Share on other sites More sharing options...
therks Posted December 24, 2007 Share Posted December 24, 2007 (edited) I don't see why the code you have is a problem anyway (did you try using Return?), but you could wrap it in a once-only loop.Func _GoApp() Do If $Var = 1 Then MsgBox(262144, "Error!", "App not found!") ContinueLoop ; Or maybe ExitLoop would be more appropriate, not sure what you're wanting exactly, so experiment Else WinActivate($App) WinWaitActive($App) EndIf Until True EndFunc Edited December 24, 2007 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
atomman Posted December 24, 2007 Author Share Posted December 24, 2007 (edited) I don't see why the code you have is a problem anyway (did you try using Return?), but you could wrap it in a once-only loop. I didn't see a problem either, but SciTE warns on ContinueLoop being outside a loop, even though technically it isn't since the func is being called inside a loop, and won't run the script. So putting it in a a loop of it's own eliminates the SciTE problem, but i'm not getting the expected result. Below i added a MsgBox() that i don't expect to ever run, but it does. As far as using Return, i think i understand basically what it's for, but i don't understand how to use it in this instance. I also tried ExitLoop in place of ContinueLoop and still get the MsgBox. While 1 $Msg = GUIGetMsg() Switch $Msg Case $Button_HlLnk _GoApp(); switch to App MsgBox(0,"","HELLO!") ; ### not expecting to see this ### ; remainder of Case ; next Case EndSwitch Func _GoApp() Do If $Var = 1 Then MsgBox(262144, "Error!", "App not found!") ContinueLoop Else WinActivate($App) WinWaitActive($App) EndIf Until True EndFunc Edited December 24, 2007 by atomman 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