Sign in to follow this  
Followers 0
Henrik

@error - Clarification question

7 posts in this topic

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.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Ah np. For some reason I alway's assume that everyone is using a beta :"> .


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

As my customer is going to use my scripts after I've left the building, I prefer to use the release version.


Ignorance is strength.

Share this post


Link to post
Share on other sites

Wise. :evil:

<{POST_SNAPBACK}>

May I quote you on that? :)

Ignorance is strength.

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