Guest timrichardson Posted May 9, 2005 Share Posted May 9, 2005 I'm new to AutoIt, although my first script is working well and has solved a big problem. I love you all, and promply made a small donation. I don't understand error trapping or error detection. Why does this not work? That is, I do not see the MsgBox. the test on @error evaluates as false. Where can I find documentation about the possible values of @error depending on the error? $answer = 1 / 0 if @error then MsgBox("Result is an error",0,0) endif Link to comment Share on other sites More sharing options...
Developers Jos Posted May 9, 2005 Developers Share Posted May 9, 2005 I'm new to AutoIt, although my first script is working well and has solved a big problem. I love you all, and promply made a small donation.I don't understand error trapping or error detection.Why does this not work?That is, I do not see the MsgBox. the test on @error evaluates as false. Where can I find documentation about the possible values of @error depending on the error? $answer = 1 / 0if @error then MsgBox("Result is an error",0,0) endif<{POST_SNAPBACK}>The value of @Error is set by the Functions used. Each functions documentation lists the possible values for @Error..for exampleReturn ValueSuccess: Returns the position of the substring. Failure: Returns 0 if substring not found. @Error 0 - Normal operation 1 - Occurance was 0. Occurance must be a positive or negative integer. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Ejoc Posted May 9, 2005 Share Posted May 9, 2005 Plus MsgBox is formatted incorrectly: MsgBox(0,"","Result it an error") Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs Link to comment Share on other sites More sharing options...
Blue_Drache Posted May 10, 2005 Share Posted May 10, 2005 Where can I find documentation about the possible values of @error depending on the error? $answer = 1 / 0if @error then MsgBox("Result is an error",0,0) endif<{POST_SNAPBACK}>As JdbE said, @error is set by a function. You only performed a simple math operation.The values of @error are dependant on the function and may have multiple meanings. You have to look at each function in the help file to see if it sets @error and to what value if an unexpected operation occurs.In your case, you'd have to put yours into a function: $answer = _divide(1, 0) If @error = 1 then MsgBox(0,"Error","Division by zero") Func _divide($x, $y) If $y = 0 then SetError(1) Return 0 Else SetError(0) Return $x/$y Endif EndFunc Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Guest timrichardson Posted May 10, 2005 Share Posted May 10, 2005 As JdbE said, @error is set by a function. You only performed a simple math operation.The values of @error are dependant on the function and may have multiple meanings. You have to look at each function in the help file to see if it sets @error and to what value if an unexpected operation occurs.In your case, you'd have to put yours into a function:thanks, I would never have expected that. Link to comment Share on other sites More sharing options...
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