AutID Posted November 26, 2013 Posted November 26, 2013 Hello,I have an infinity while...wend loop. Within the while loop i have a for...next loop.In the for/next loop i am calling a function and checking if it returns an error or a value, something like this:Local $hState = 1 While (True) If $hState Then For $i = 0 To 10 $sFunc = _myFanc() If @error Then ConsoleWrite("Error: " & @error & @CRLF) ExitLoop ;will exit for/next loop and restart the whole proccess Else ConsoleWrite($sFunc & @CRLF) EndIf Next EndIf Sleep(100) WEndHowever if the $sFunc returns an error once, everytime the loop is restarted it will return the same error.In _myFunc() i have 3 SetErrorsSetError(1)SetError(2)SetError(3).Any ideas? I haven't quitly used SetError function so i am not sure if my bug is that function.Cheers https://iblockify.wordpress.com/
water Posted November 26, 2013 Posted November 26, 2013 According to the help file for SetError: "When entering a function @error is set to 0" If your function returns @error <> 0 then either an error occurred in your function or you have called SetError. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AutID Posted November 26, 2013 Author Posted November 26, 2013 I have called seterror in my function. My func checks for a name in a ini file. If the name exists it returns the name, else it returns seterror depending of the names in the ini file. When i call _myFunc for the first time if the name doesnt exists it returns the @error set from seterror. When i call it a second time, since it is an infinity loop, i think the func doesnt run. It returns the same @error it returned the first time it was called even if the name exists... https://iblockify.wordpress.com/
water Posted November 26, 2013 Posted November 26, 2013 Sorry, but it is not possible to help you without seeing the full code. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
AutID Posted November 26, 2013 Author Posted November 26, 2013 Sorry, but it is not possible to help you without seeing the full code.Ahh i played a little bit more with it and found my error._myFunc has a text in it stored and based on that text it returns the errors via SetError.When i called the function it was checking the text and returning the error. Then i was using ExitLoop. However the $text var inside the _myFunc function was still the same since it is in Global scope and the function was returning the same error again and again each time it was called. So i just refreshed the $text before the exitloop and fix it.Local $hState = 1 While (True) If $hState Then For $i = 0 To 10 $sFunc = _myFanc() If @error Then ConsoleWrite("Error: " & @error & @CRLF) $text = "" ExitLoop ;will exit for/next loop and restart the whole proccess Else ConsoleWrite($sFunc & @CRLF) EndIf Next EndIf Sleep(100) WEnd https://iblockify.wordpress.com/
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