Sign in to follow this  
Followers 0
PcExpert

Set a global error

7 posts in this topic

#1 ·  Posted (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 by PcExpert

Share this post


Link to post
Share on other sites



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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Ah, I see, yes, that sounds a little more reasonable. :D

Share this post


Link to post
Share on other sites

Thats exactly what I want. Thanks!

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