jer Posted April 1, 2010 Posted April 1, 2010 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.
KaFu Posted April 1, 2010 Posted April 1, 2010 It's @error OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
jer Posted April 2, 2010 Author Posted April 2, 2010 Sorry, I meant any reference to @exitcode produces a run-time error "Error: Unknown macro".
KaFu Posted April 2, 2010 Posted April 2, 2010 This works fine for me: OnAutoItExitRegister("_Exit") Exit(7) Func _Exit() MsgBox(0,"@ExitCode",@exitCode) EndFunc OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
jvanegmond Posted April 2, 2010 Posted April 2, 2010 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). github.com/jvanegmond
jer Posted April 2, 2010 Author Posted April 2, 2010 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.
PsaltyDS Posted April 2, 2010 Posted April 2, 2010 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
KaFu Posted April 2, 2010 Posted April 2, 2010 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." OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
trancexx Posted April 2, 2010 Posted April 2, 2010 And besides that, this is perfectly valid:MsgBox(64, "rc5", "Will exit now") Exit 5 ConsoleWrite(@exitCode & @CRLF) ♡♡♡ . eMyvnE
PsaltyDS Posted April 2, 2010 Posted April 2, 2010 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
trancexx Posted April 2, 2010 Posted April 2, 2010 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
PsaltyDS Posted April 2, 2010 Posted April 2, 2010 I know what I wrote.So do we. Just not what you meant! 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
trancexx Posted April 2, 2010 Posted April 2, 2010 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
KaFu Posted April 2, 2010 Posted April 2, 2010 What if I write a script that will not exit on Exit...Been there, done that ... OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
PsaltyDS Posted April 2, 2010 Posted April 2, 2010 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now