faldo Posted March 6, 2009 Share Posted March 6, 2009 I remember a few versions back, i used to get a whole lot of "recursion error" (or something like that) in Do...Until-loops when i had the script running for a few days in a row accessing the loop. I solved the problem by useing While...wend-loops instead but i have one question that still haunts me. If i have the following loop: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() EndIf Until @error Func NextFunction() ;~ blablabla EndFunc ...will it terminate the loop when i "goto" the next function or will the loop continue in the background? Do i need to use Exitloop just in case, like this: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() Exitloop EndIf Until @error Func NextFunction() ;~ blablabla EndFunc Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API Link to comment Share on other sites More sharing options...
BlackPhoenix Posted March 6, 2009 Share Posted March 6, 2009 I remember a few versions back, i used to get a whole lot of "recursion error" (or something like that) in Do...Until-loops when i had the script running for a few days in a row accessing the loop. I solved the problem by useing While...wend-loops instead but i have one question that still haunts me. If i have the following loop: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() EndIf Until @error Func NextFunction() ;~ blablabla EndFunc ...will it terminate the loop when i "goto" the next function or will the loop continue in the background? Do i need to use Exitloop just in case, like this: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() Exitloop EndIf Until @error Func NextFunction() ;~ blablabla EndFuncDim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() Msgbox(0,'','Yes it continues but goes to Nextfunctionfirst() ^^ ') Exitloop EndIf Until @error Func NextFunction() Msgbox(0,'','Some text here') EndFunc Try running this, i think you'll have your answer Link to comment Share on other sites More sharing options...
Andreik Posted March 6, 2009 Share Posted March 6, 2009 (edited) I remember a few versions back, i used to get a whole lot of "recursion error" (or something like that) in Do...Until-loops when i had the script running for a few days in a row accessing the loop. I solved the problem by useing While...wend-loops instead but i have one question that still haunts me. If i have the following loop: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() EndIf Until @error Func NextFunction() ;~ blablabla EndFunc ...will it terminate the loop when i "goto" the next function or will the loop continue in the background? Do i need to use Exitloop just in case, like this: Dim $count=1 Do $count=$count+1 If $count=10 Then $count=1 MsgBox(0, "", "Count is 10") NextFunction() Exitloop EndIf Until @error Func NextFunction() ;~ blablabla EndFuncThe loop will not terminated without an error or ExitLoop. Edited March 6, 2009 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 6, 2009 Moderators Share Posted March 6, 2009 faldo.In your first snippet when $count = 10 you will in order: reset $count=1; show the MsgBox(0, "", "Count is 10"); and then run NextFunction(). When NextFunction returns, the Do...Until loop will continue until $icount reaches 10 again, when the whole process repeats. This will go on until @error is set by the returning NextFunction. So continuing passes through NextFunction until it errors.In your second snippet, when $count = 10 you do the same things in the same order, but when NextFunction returns, ExitLoop will (unsurprisingly) exit the Do...Until loop - i.e. only one pass through NextFunction. Actually, as there is only the one pass, you need not reset $count (because it is never used again within the loop) and the Until @error becomes pretty moot (as the only line which would ever trigger it is $count=$count+1 - and if that forces an error you are in big trouble :-)). In fact, you might as well use a For...Next loop.I hope this is clear.M23P.S. In place of $count=$count+1, did you know you can use $count += 1? Look in the Help file under 'Language Reference - Operators' 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...
faldo Posted March 6, 2009 Author Share Posted March 6, 2009 (edited) I thought the loop would end if i "goto" a functions outside the loop since autoit can't handle multiple "threads". I thought i had to use the "call"-function in order to still run the loop and use a function from within the loop. I'm glad i got that answered, thanx for the quick reply guys. Edited March 6, 2009 by faldo Check out my other scripts: RDP antihammer/blacklist generator | Phemex cryptocurrency exchange API 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