qwerz123 Posted June 4, 2012 Share Posted June 4, 2012 Hello! I would ask you guys is there a way to skip everything in a loop and begin again when variable in a function in the loop is 0? Sorry for my bad english better if i give an example While 1 Function1 Function2 Function3 WEnd Func Function2 $c=checkSomething() If $c=0 Then HERE -> ;some function to skip this function and Function3 in a loop and start again with function1 EndIf function continues... function continues... function continues... EndFunc I know that i can make a variable and check at the beginning in every function in a loop but maybe there is a better way. Thanks for your answers Best regards Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 4, 2012 Moderators Share Posted June 4, 2012 qwerz123, Welcome to the AutoIt forum. Something like this should do what you want: While 1 Function1() If Function2() = 1 Then ; If the return was 1 we continue Function3() EndIf WEnd Func Function2() $c = checkSomething() If $c = 0 Then Return 0 ; Do not continue EndIf function continues... function continues... function continues... Return 1 ; Continue EndFunc ;==>Function2 Please ask if you have any questions. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted June 4, 2012 Moderators Share Posted June 4, 2012 (edited) Hi, qwerz123. It depends on where your variable is being set. You could do something like this:Global $c While 1 _Func1() If $c <> 1 Then _Func2() _Func3() EndIf WEnd Func _Func1() MsgBox(0, "Test", "Hello 1!") $c = 1 EndFunc Func _Func2() MsgBox(0, "Test", "Hello 2!") EndFunc Func _Func3() MsgBox(0, "Test", "Hello 3!") EndFuncEdit: !@##%$#@! Edited June 4, 2012 by JLogan3o13 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
water Posted June 4, 2012 Share Posted June 4, 2012 Something like this?While 1 Function1 Function2 If @error <> 1 Then Function3 WEnd Func Function2 $c=checkSomething() If $c=0 Then Return SetError(1) function continues... function continues... function continues... EndFunc Exits the function and sets macro @error = 1. Function3 is executed only when @error <> 1. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 4, 2012 Moderators Share Posted June 4, 2012 Now that is what you call service! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
water Posted June 4, 2012 Share Posted June 4, 2012 Three different solutions in the same minute . qwerz123 it's now up to you to select a solution My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
qwerz123 Posted June 4, 2012 Author Share Posted June 4, 2012 Wow! Thanks guys! I was thinking too same way like your examples. But when there 2 or 3 variables to check every time the code becomes more complicated for writing and reading. But that's ok. Creating something new is never a easy job, isn't it? Thanks again. Best regards! Link to comment Share on other sites More sharing options...
Mechaflash Posted June 4, 2012 Share Posted June 4, 2012 (edited) While 1 Function1 If Not Function2 Then ContinueLoop Function3 WEnd Func Function2 $c=checkSomething() If $c=0 Then Return False function continues... function continues... function continues... EndFunc I can haz win? Edited June 4, 2012 by mechaflash213 Spoiler “Hello, ladies, look at your man, now back to me, now back at your man, now back to me. Sadly, he isn’t me, but if he stopped using ladies scented body wash and switched to Old Spice, he could smell like he’s me. Look down, back up, where are you? You’re on a boat with the man your man could smell like. What’s in your hand, back at me. I have it, it’s an oyster with two tickets to that thing you love. Look again, the tickets are now diamonds. Anything is possible when your man smells like Old Spice and not a lady. I’m on a horse.” 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