Sign in to follow this  
Followers 0
AutID

SetError returned error

5 posts in this topic

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)
WEnd
However if the $sFunc returns an error once, everytime the loop is restarted it will return the same error.

In _myFunc() i have 3 SetErrors

SetError(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

Share this post


Link to post
Share on other sites



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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

Sorry, but it is not possible to help you without seeing the full code.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0