Errors
See also: compiling and debugging,
err, #err.
Compile-time errors
Compile-time errors are generated when compiling
macros that contain syntax errors. Macros are compiled before they start. They
don't start if there are syntax errors. The first syntax error is displayed
in the QM output like "Error in Macro: error description". Compile-time
errors are not generated in exe, because
in exe the macro is already compiled.
Some compile-time errors and possible reasons/solutions:
- unknown identifier:
- Forgot to declare
a variable or other identifier. Declaration must go before usage.
- Character
case mismatch. For example, if a function is MyFunc, error if you use Myfunc.
- Forgot to enclose
in "" a string argument (window title, file path, etc).
- The function/type/etc is not available in this QM version. It may happen if the macro author
is not you. Upgrade QM.
- unexpected identifier:
- This type of identifier cannot be used here.
- unexpected character:
- Names of variables and other identifiers
must consist of alphanumeric characters and underscore, and cannot begin with
a digit.
- Incorrect syntax.
- missing parts:
- Forgot some argument or other parts of the command/function/etc.
- too many parts:
- Forgot to enclose in "" a string argument.
- Forgot ; after
statement that is followed by more statements in the same line.
- If a function argument is quite complex expression (e.g., a.r[i].right-a.r[i].left ), enclose it in parentheses.
- missing ( after function name, or ; after statement:
- The same
reasons as above.
- The ( must immediately follow function name. Correct: Func(.... Error: Func (....
- else without if:
- Indentation (number of tabs) of else must match indentation of its if.
- case without sel:
- Indentation (number of tabs) of case must be one more than indentation of its sel.
- expected numeric (or string) expression:
- Used a string where there
must be a numeric value, or vice versa.
- Forgot some argument.
- expected int, integer constant, etc:
- Similar reasons as above.
- expected int*, etc:
- Must be address of a variable (e.g., Function(&var),
but not Function(var) ). Variable type also must match expected. For type casting, use operator
+.
- ... already exists or is declared:
- Declaring a variable
or other identifier while it is already somewhere declared differently.
- Declaring a local variable more than once in the same function.
- expected x (to y) arguments ...:
- Forgot some arguments. When calling
a function, the number of arguments must match the number
of parameters in function's declaration (function, dll, etc).
- syntax:
- other error.
- Exception while compiling:
- An internal QM error. Try to restart
QM.
- If QM reports a false error (possibly a bug), try to restart QM.
Run-time errors
Run-time errors are generated while macro is executed. On a run-time
error the macro ends. In the QM output is displayed error description, like
"Error (RT) in Macro: error description".
There are three groups of run-time errors:
1. Errors that are generated by QM ("Window not found", "File
not found", etc). Such errors can be handled with the err
statement. There are also several fatal errors that cannot be handled, such
as a noncompiled function containing syntax errors.
2. Errors that are generated using the end
statement. Such errors can be handled with err.
3. Exceptions (errors generated by the operating system or components). In
most cases it is result of incorrect programming (invalid pointer, division
by 0, endless recursion, etc). Exceptions can by handled with err, but you should avoid them if possible.
Some run-time errors and possible reasons/solutions:
- Window not found:
- Window name must match case.
- Window is hidden:
use opt hidden 1 before, or use class name.
- Part of window name (e.g., document
name) now is different than when recording. Use partial name.
- Menu item or button not found:
- Underlined characters must be
preceded by &. To view underlined characters, expand menu with the keyboard
(Alt+...).
- Nonstandard menu.
- If button class name does not have "Button"
or "Btn", don't use but name [window]. Instead use id or child function.
- Button cannot be found using its text because has "owner-draw"
style. Try function id, or child(x
y), or scan.
- 0x80020003, Member not found (with accessible objects):
- The
accessible object does not support this feature.
- The window is inactive. Use act to activate it.
- object not found, and other:
- The macro runs too fast. Insert wait or change
macro speed (spe).
- cannot paste:
- The focused control is not editable.
- The focused control does not support Ctrl+V. Some controls use Shift+Insert instead.
- The focused control does not support this clipboard format.
- The window is disabled or hung.
- The window has higher integrity level. Eg, QM runs as User, and the target program runs as Administrator.