Jump to content

@errorcode produces a run-time error


 Share

Recommended Posts

Any reference to @errorcode produces a run-time error "Error: Unknown macro". Is @errorcode still a valid macro??? It still appears in the 3.3.6.0 help file. No mention in history/change log.

Link to comment
Share on other sites

Sorry, I meant any reference to @exitcode produces a run-time error "Error: Unknown macro".

You can only use @exitCode in a function registered by OnAutoItExitRegister or the old way in a function called OnAutoItExit. These are called once the Exit method is called, and the actual @exitCode is set. Otherwise, the @exitCode is not set and you will get a "Error: Unknown macro" error. (Because, at the time of calling the macro's value is unknown).
Link to comment
Share on other sites

You can only use @exitCode in a function registered by OnAutoItExitRegister or the old way in a function called OnAutoItExit. These are called once the Exit method is called, and the actual @exitCode is set. Otherwise, the @exitCode is not set and you will get a "Error: Unknown macro" error. (Because, at the time of calling the macro's value is unknown).

Thanks for the clarification. This explanation would be a great addition to the Autoit Help file, which does not mention this limitation! If calling without using OnAutoItExitRegister, the error indicates that that the @exitcode macro does not exist, which seems to be a bug. If it does not yet have a value, then it should return null or blank. Thanks again.

post-57062-12702307935915_thumb.gif

Link to comment
Share on other sites

Lots of other macros work the same way. For example @GUI_WinHandle, @GUI_CtrlHandle, and @Tray_Id are only valid in the appropriate event functions. It is what it is.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

This explanation would be a great addition to the Autoit Help file, which does not mention this limitation!

It's there, that's how I found it...

Index => @exitcode => "Exit code as set by Exit statement." => Exit => "The code can be retrieved in an OnAutoItExitRegister function by @EXITCODE."

Link to comment
Share on other sites

And besides that, this is perfectly valid:

MsgBox(64, "rc5", "Will exit now")
Exit 5
ConsoleWrite(@exitCode & @CRLF)
That doesn't produce an error, but the ConsoleWrite() line is never evaluated. You will get an error if the @exitcode macro is actually evaluated outside of the proper event function:
MsgBox(64, "rc5", "Will exit now:  @exitCode = " & @exitCode)
Exit 5
ConsoleWrite("@exitCode = " & @exitCode & @CRLF)

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

So do we.

What if I write a script that will not exit on Exit but continue executing for few more seconds and then exit for real.

Would that code of mine from the few posts up produce "Error: Unknown macro" error? What do you think?

@exitcode macro will be evaluated outside of the proper event function.

Speak now.

♡♡♡

.

eMyvnE

Link to comment
Share on other sites

What if I write a script that will not exit on Exit but continue executing...

I used to write scripts like that all the time. :(

But I've gotten much better at it since then!

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...