Jump to content

@error - Clarification question


Recommended Posts

The @error code is only valid until the next function is called

I need to know precisely what 'valid' means.

If @error must be inspected after a function call, is it then good practice to call SetError(0) before the call ?

If I understand correctly, a function may set @error:

AFunction()
AnotherFunction()

func AFunction()
   SetError(42)
endfunc

func AnotherFunction()
endfunc

What will happen if @error is referenced after these 2 function calls? Does @error contain the value 42? Or is it invalid in another sense?

Disclaimer: Yes, I tried both RTFM & forum search, but got no wiser. And of course I could experiment :) , however I think this issue ought to be clarified in the helpfile.

Ignorance is strength.

Link to comment
Share on other sites

Disclaimer: Yes, I tried both RTFM & forum search, but got no wiser. And of course I could experiment :) , however I think this issue ought to be clarified in the helpfile.

<{POST_SNAPBACK}>

The help file is clear and it state's exactly what should happen. Please be able to support your above qoute next time by actually reading the help file :evil:.

From the help file... > SetError ()

When entering a function @error is set to 0. Unless SetError() is called, then @error will remain 0 after the function has ended. This means that in order for @error to be set after a function, it must be explicitly set. This also means you may need to backup the status of @error in a variable if you are testing it in a While-WEnd loop.

Edited by Burrup

qq

Link to comment
Share on other sites

When entering a function @error is set to 0

Thanks, exactly what I needed to know.

Please be able to support your above qoute next time by actually reading the help file :).

<{POST_SNAPBACK}>

The helpfile I read came with the v3.1.1 AutoIt installation. In the future, I'll make sure to check both the released & the latest beta version of the helpfile. Then, if there are differences, I might ask on the forums whether the helpfile changes are clarifications or reflect actual changes between the release and the beta versions of AutoIt.

Ignorance is strength.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...