end [errorstring] [flags] [...]
errorstring - error description. Can be string or variable of type QMERROR.
flags :
| 0-3 | Where to generate error:
|
| 4 | Don't open function even if "Show run-time errors" is checked in Options. |
| 8 | QM 2.3.3. Generate warning. |
... - values that are inserted into the format-string (errorstring).
Generates run-time error, which ends thread (running macro) if not handled.
By default, if end is used in an user-defined function, the error is generated in caller (macro/function that called the function).
Caller can handle errors with err statement. Then it may want to know error code. It looks for it in code field of the _error variable. There are several ways to set error code when generating error:
QM 2.3.3. If used flag 8, generates warning instead of error. It does not end macro. Just displays warning message in QM output. Flags 0-3 are applied. To disable such warnings, use opt nowarnings 1.
In function help you can see errors that the function may generate. QM displays errors from end statements used in that function, or errors explicitly specified in Errors: line.
If end is used without arguments (just end), it ends thread without generating error. This way of ending thread is rarely used. Instead use ret or generate error. In some cases it is better to use shutdown -7.
See also: opt end
end "file not found" end "2000 my error description" ;;use an error code end ERR_FILE ;;use an error constant str filevariable="Z:\file" end F"{ERR_FILE}: '{filevariable}'" run "abc" err _error.description + " abc" end _error end ;;end thread without generating error