Jump to content

Set a global error


 Share

Recommended Posts

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 by PcExpert
Link to comment
Share on other sites

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

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

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.

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...