Search the Community
Showing results for tags 'setexitcode'.
-
We get new features but the awareness does not propagate and become common knowledge fast enough so, here is an example of use: Opt("SetExitCode", 1) OnAutoItExitRegister("__OnAutoItExit") Example() Func Example() Local $n, $a[6] = [5, 5, 4, 3, 2, 1] For $n = 1 To 100 ToolTip('..crashing in ' & $a[$n], 50, 50, "CrashTest") ConsoleWrite('..crashing in ' & $a[$n] & @CRLF) Sleep(500) Next EndFunc ;==>Example Func __OnAutoItExit() Local $sExitMethod Switch @exitMethod Case 0 $sExitMethod = "closed by natural closing." Case 1 $sExitMethod = "closed by Exit function." Case 2 $sExitMethod = "closed by clicking on exit of the systray." Case 3 $sExitMethod = "closed by user logoff." Case 4 $sExitMethod = "closed by Windows shutdown." Case Else $sExitMethod = "closed by no clue." EndSwitch ;~ If @exitCode Then MsgBox(262144, @ScriptName, "I could do something with the error from here", 2) MsgBox(262144, @ScriptName, "Oh !, wait, we now can =)" & @CR & _ @CR & "The error was: " & Hex(@exitCode) & _ @CR & "Meaning: """ & FatalErrormessageFromExitCode(@exitCode) & """" & _ @CR & "and the ExitMethod was """ & $sExitMethod & """" & _ @CR & @CR & " =)", 60) EndFunc ;==>__OnAutoItExit Func FatalErrormessageFromExitCode($iExitCode) ; from the help file Local $sExitCode = 'uncatalogued event' Switch $iExitCode Case 0x7FFFF068 $sExitCode = '"EndWith" missing "With". ' Case 0x7FFFF069 $sExitCode = 'Badly formatted "Func" statement. ' Case 0x7FFFF06A $sExitCode = '"With" missing "EndWith". ' Case 0x7FFFF06B $sExitCode = 'Missing right bracket '') '' in expression. ' Case 0x7FFFF06C $sExitCode = 'Missing operator in expression. ' Case 0x7FFFF06D $sExitCode = 'Unbalanced brackets in expression. ' Case 0x7FFFF06E $sExitCode = 'Error in expression. ' Case 0x7FFFF06F $sExitCode = 'Error parsing function call. ' Case 0x7FFFF070 $sExitCode = 'Incorrect number of parameters in function call. ' Case 0x7FFFF071 $sExitCode = '"ReDim" used without an array variable. ' Case 0x7FFFF072 $sExitCode = 'Illegal text at the end of statement (one statement per line). ' Case 0x7FFFF073 $sExitCode = '"If" statement has no matching "EndIf" statement. ' Case 0x7FFFF074 $sExitCode = '"Else" statement with no matching "If" statement. ' Case 0x7FFFF075 $sExitCode = '"EndIf" statement with no matching "If" statement. ' Case 0x7FFFF076 $sExitCode = 'Too many "Else" statements for matching "If" statement. ' Case 0x7FFFF077 $sExitCode = '"While" statement has no matching "WEnd" statement. ' Case 0x7FFFF078 $sExitCode = '"WEnd" statement with no matching "While" statement. ' Case 0x7FFFF079 $sExitCode = 'Variable used without being declared. ' Case 0x7FFFF07A $sExitCode = 'Array variable has incorrect number of subscripts or subscript dimension range exceeded. ' Case 0x7FFFF07B $sExitCode = 'Variable subscript badly formatted. ' Case 0x7FFFF07C $sExitCode = 'Subscript used on non-accessible variable. ' Case 0x7FFFF07D $sExitCode = 'Too many subscripts used for an array. ' Case 0x7FFFF07E $sExitCode = 'Missing subscript dimensions in "Dim" statement. ' Case 0x7FFFF07F $sExitCode = 'No variable given for "Dim", "Local", "Global", "Static" or "Const" statement. ' Case 0x7FFFF080 $sExitCode = 'Expected a "=" operator in assignment statement. ' Case 0x7FFFF081 $sExitCode = 'Invalid keyword at the start of this line. ' Case 0x7FFFF082 $sExitCode = 'Array maximum size exceeded. ' Case 0x7FFFF083 $sExitCode = '"Func" statement has no matching "EndFunc". ' Case 0x7FFFF084 $sExitCode = 'Duplicate function name. ' Case 0x7FFFF085 $sExitCode = 'Unknown function name. ' Case 0x7FFFF086 $sExitCode = 'Unknown macro. ' Case 0x7FFFF088 $sExitCode = 'Unable to get a list of running processes. ' Case 0x7FFFF08A $sExitCode = 'Invalid element in a DllStruct. ' Case 0x7FFFF08B $sExitCode = 'Unknown option or bad parameter specified. ' Case 0x7FFFF08C $sExitCode = 'Unable to load the internet libraries. ' Case 0x7FFFF08D $sExitCode = '"Struct" statement has no matching "EndStruct". ' Case 0x7FFFF08E $sExitCode = 'Unable to open file, the maximum number of open files has been exceeded. ' Case 0x7FFFF08F $sExitCode = '"ContinueLoop" statement with no matching "While", "Do" or "For" statement. ' Case 0x7FFFF090 $sExitCode = 'Invalid file filter given. ' Case 0x7FFFF091 $sExitCode = 'Expected a variable in user function call. ' Case 0x7FFFF092 $sExitCode = '"Do" statement has no matching "Until" statement. ' Case 0x7FFFF093 $sExitCode = '"Until" statement with no matching "Do" statement. ' Case 0x7FFFF094 $sExitCode = '"For" statement is badly formatted. ' Case 0x7FFFF095 $sExitCode = '"Next" statement with no matching "For" statement. ' Case 0x7FFFF096 $sExitCode = '"ExitLoop/ContinueLoop" statements only valid from inside a For/Do/While loop. ' Case 0x7FFFF097 $sExitCode = '"For" statement has no matching "Next" statement. ' Case 0x7FFFF098 $sExitCode = '"Case" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF099 $sExitCode = '"EndSelect" statement with no matching "Select" statement. ' Case 0x7FFFF09A $sExitCode = 'Recursion level has been exceeded - AutoIt will quit to prevent stack overflow. ' Case 0x7FFFF09B $sExitCode = 'Cannot make existing variables static. ' Case 0x7FFFF09C $sExitCode = 'Cannot make static variables into regular variables. ' Case 0x7FFFF09D $sExitCode = 'Badly formated Enum statement ' Case 0x7FFFF09F $sExitCode = 'This keyword cannot be used after a "Then" keyword. ' Case 0x7FFFF0A0 $sExitCode = '"Select" statement is missing "EndSelect" or "Case" statement. ' Case 0x7FFFF0A1 $sExitCode = '"If" statements must have a "Then" keyword. ' Case 0x7FFFF0A2 $sExitCode = 'Badly formated Struct statement. ' Case 0x7FFFF0A3 $sExitCode = 'Cannot assign values to constants. ' Case 0x7FFFF0A4 $sExitCode = 'Cannot make existing variables into constants. ' Case 0x7FFFF0A5 $sExitCode = 'Only Object-type variables allowed in a "With" statement. ' Case 0x7FFFF0A6 $sExitCode = '"long_ptr", "int_ptr" and "short_ptr" DllCall() types have been deprecated. Use "long*", "int*" and "short*" instead. ' Case 0x7FFFF0A7 $sExitCode = 'Object referenced outside a "With" statement. ' Case 0x7FFFF0A8 $sExitCode = 'Nested "With" statements are not allowed. ' Case 0x7FFFF0A9 $sExitCode = 'Variable must be of type "Object". ' Case 0x7FFFF0AA $sExitCode = 'The requested action with this object has failed. ' Case 0x7FFFF0AB $sExitCode = 'Variable appears more than once in function declaration. ' Case 0x7FFFF0AC $sExitCode = 'ReDim array can not be initialized in this manner. ' Case 0x7FFFF0AD $sExitCode = 'An array variable can not be used in this manner. ' Case 0x7FFFF0AE $sExitCode = 'Can not redeclare a constant. ' Case 0x7FFFF0AF $sExitCode = 'Can not redeclare a parameter inside a user function. ' Case 0x7FFFF0B0 $sExitCode = 'Can pass constants by reference only to parameters with "Const" keyword. ' Case 0x7FFFF0B1 $sExitCode = 'Can not initialize a variable with itself. ' Case 0x7FFFF0B2 $sExitCode = 'Incorrect way to use this parameter. ' Case 0x7FFFF0B3 $sExitCode = '"EndSwitch" statement with no matching "Switch" statement. ' Case 0x7FFFF0B4 $sExitCode = '"Switch" statement is missing "EndSwitch" or "Case" statement. ' Case 0x7FFFF0B5 $sExitCode = '"ContinueCase" statement with no matching "Select" Or "Switch" statement. ' Case 0x7FFFF0B6 $sExitCode = 'Assert Failed! ' Case 0x7FFFF0B8 $sExitCode = 'Obsolete function/parameter. ' Case 0x7FFFF0B9 $sExitCode = 'Invalid Exitcode (reserved for AutoIt internal use). ' Case 0x7FFFF0BA $sExitCode = 'Variable cannot be accessed in this manner. ' Case 0x7FFFF0BB $sExitCode = 'Func reassign not allowed. ' Case 0x7FFFF0BC $sExitCode = 'Func reassign on global level not allowed. ' EndSwitch Return SetError(0, $iExitCode, $sExitCode) EndFunc ;==>FatalErrormessageFromExitCode #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/mo #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here Opt("SetExitCode", 1) If $CmdLine[0] = 0 Then ; https://www.autoitscript.com/autoit3/docs/appendix/Exitcodes.htm ; for CUI compile, adding "/ErrorStdOut" will write out the line number and error description" ; "(8) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" MsgBox(262144, "ExitCode:", "0x" & Hex(RunWait('"' & @AutoItExe & '" /ErrorStdOut ' & (@Compiled ? '' : '"' & @ScriptFullPath & '" ') & '/crash')), 8) ElseIf $CmdLine[1] = "/crash" Then $CmdLine[100] = "hmmm" EndIf Edit: There are wrapper functions in v3.3.16.1 but did not know, otherwise I'd have saved me the coding. These func. are _FormatAutoItExitCode() and _FormatAutoItExitMethod() . I created the post after reviewing my tracs and decided to bla, bla, bla ... , and posted
- 1 reply
-
- setexitcode
- opt
-
(and 2 more)
Tagged with: