Jump to content

Recommended Posts

Posted

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.

Posted

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

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

Posted

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

Posted

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
Posted

Description for @exitCode is "Exit code as set by Exit statement".

Nobody guaranties @exitCode exists before it's set. Therefore evaluating before setting is wrong.

I know what I wrote.

♡♡♡

.

eMyvnE

Posted

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

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
×
×
  • Create New...