PcExpert Posted January 20, 2008 Share Posted January 20, 2008 (edited) Hi all, Is it possible to set a global error? So instead of $MyVar < Undeclared variable . I get 'An error occured, please contact bla bla bla' I noticed SetError, but I dont think that it does this. Thanks! Edited January 20, 2008 by PcExpert Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 From what I'm aware of, No, you can't set a Global @Error, but you can store the value of it in a variable: $Error = @Error Link to comment Share on other sites More sharing options...
martin Posted January 20, 2008 Share Posted January 20, 2008 Hi all,Is it possible to set a global error? So instead of $MyVar < Undeclared variable . I get 'An error occured, please contact bla bla bla' I noticed SetError, but I dont think that it does this.Thanks!Can you show a bit of the code where you get this problem, and say when this error occurs? I don't recognize the message you quote and I'm not sure I understand. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 I think what he wanted is a way of checking if @Error was set even after a successfull command was run.. For example, if it's a function then I'd do this: $a = _MyFunc() If @error Or $a = 0 Then MsgBox(0, "", "An error occured in your function!") EndIf Func _MyFunc() FileRead("blaahaaa") ; will trigger the error If @Error Then SetError(@Error) Return 0 Endif EndFunc Link to comment Share on other sites More sharing options...
therks Posted January 20, 2008 Share Posted January 20, 2008 Can you show a bit of the code where you get this problem, and say when this error occurs? I don't recognize the message you quote and I'm not sure I understand. I think he just wants to be able to replace AutoIt syntax errors with his own notifications. So that the following script: $MyVar = 1 If $MyVar < $NoVar Then EndIf Wouldn't give him this:Variable used without being declared.: If $MyVar < $NoVar Then If $MyVar < ^ ERROR It would give him a custom error message of his own. In which case, no, you can't. It was asked for in feature requests and I'm pretty sure it was rejected. Just write your code without errors. My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
FreeFry Posted January 20, 2008 Share Posted January 20, 2008 Ah, I see, yes, that sounds a little more reasonable. Link to comment Share on other sites More sharing options...
PcExpert Posted January 20, 2008 Author Share Posted January 20, 2008 Thats exactly what I want. Thanks! 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