Sign in to follow this  
Followers 0
jer

@errorcode produces a run-time error

15 posts in this topic

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.

Share this post


Link to post
Share on other sites



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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

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

Share this post


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

Share this post


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

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