Sign in to follow this  
Followers 0
kparker

@error question

2 posts in this topic

I did look at the help file and did not see an indicator of the answer.  The @error variable that inherits a value when a function produces an error; is this value overwritten as success if a function right below it is successful?   It seems that I could possibly check the error value at the end of a UDF if it always maintains an error value once generated, but if its overwritten by successful functions, I would have to check every function call.  I find this more relevant for browser automation.  i.e. checking every time I navigate.

 

Share this post


Link to post
Share on other sites



Yes, @error changes after MOST UDF/Procedure calls.  This is why error checking is so tedious :P

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

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello, I recently opened a bug report without reading the Helpfile... My bad . After @Melba23's gentle reminder, I was curious about why it was like that.
      It is about SetError's behaviour. This is the example from the bug report:
      Example() If @error Then ConsoleWrite("Error" & @CRLF) Else ConsoleWrite("No Error" & @CRLF) EndIf Func Example() SetError(1) Sleep(1000) EndFunc What I tried to do is set Example's (my user defined function's) @error value to 1... but the value set by SetError is cleared after calling a function, I wonder why? Why should calling to an external function effect my function's @error which is set when my function returns.
      Setting the error of a UDF in advance by using SetError makes sense... but I cannot find a reason why calling a function should clear it? Please note that I am not talking about @error, I am talking about the @error set by my function when it ends/returns!
      I hope someone can enlighten me, thanks for the answers in advance!
      P.S I tried to explain my best but my English is not very good and I didn't feel like I did a good job explaining today, so please pardon any mistakes that I have made
    • PEscobar
      By PEscobar
      So I made a loop beginning with while $e = 1. It opens a file and searches for a colour in the file, if the colour isn't there $e = 2 so the loop ends and restarts. Instead of that, the loop runs once and then just stops completely, even if the colour is there. 
      Here is what it looks like basically.
      While $e = 1 
          OpenPng()
            $aCoord = PixelSearch ($left, $top, $right, $bottom, 0x3B5E05, 0)
            If @error Then $e = 2
      WEnd
      How do I make it so the loop restarts if the colour isn't there, but it continues normally if the colour is there?
       
       
    • Reptos
      By Reptos
      How should i go about repeating this section if@error? I want it to try again if it can not find the PixelSearch then move on to the next Search.
      While 1
          $cords = PixelSearch(564, 188,710, 350,0x380030)
         If Not (@error) Then
            MouseClick("Left",$cords[0],$cords[1],1,1)
            EndIf
            If (@error) Then
              ??????
            EndIf
    • TheDcoder
      By TheDcoder
      Hello , I was thinking of a situation where a key in a ini file can contain anything, If we were to know if the key does not exists using IniRead, Its not possible to do it without compromising a single possibility... I was thinking that if IniRead were to set @error when a key does not exist, it solves the problem which I mentioned before
       
      What do you think? Would you like this feature?
      TD
    • hemichallenger
      By hemichallenger
      Func MyErrFunc() Local $HexNumber If IsObj($oMyError) Then $HexNumber = Hex($oMyError.number, 8) GUICtrlSetData($GreenProgress,"") _RedProgress() GUICtrlSetData($Output,"") GUICtrlSetData($Output, "Intercepted a COM ""Component Object Model"" Error with the computer!" & @CRLF & @CRLF & _ "Description : " & $oMyError.windescription, 10) SetError($HexNumber) EndIf SetError (1) Return EndFunc Has anyone ran into the issue with a COM error crashing your script? The script works and catches the error twice and then the third time it crashes the script "The RPC server is unavailable.". The script looks up the computer and grabs there MAC address and IP thru WMI.