Predefined/special variables and constants

Local variables

_i - variable of type int. It is normal local variable except that you don't have to declare it.

 

_s - variable of type str. The same as above.

 

this - reference to the variable for which current member-function is called.

Thread variables

_command - command string of current thread. Type - lpstr. If thread started without command, it is 0. See also: mac, QM command line.

 

_hresult - last called COM function's error code. Some other functions also use it.

 

_error - error info.

 

_monitor - monitor where various functions display dialogs, on-screen text, etc. You can change it to display them in certain monitor. Possible values:

 

_monitor is applied to these functions: mes, inp, inpp, OnScreenDisplay, ListDialog, ShowDialog, and most functions that use them. Some other functions either have a monitor parameter instead, or a flag that tells to use _monitor.

 

Examples

 

 display message box in monitor 2
_monitor=2
mes "text"

 display on-screen text in monitor with the mouse pointer, and restore the variable
_i=_monitor; _monitor=-1
OnScreenDisplay "text"
_monitor=_i

 

Most of these variables normally are populated by QM, but you also can change some of them.

 

Also there are 10 int variables tls0 ... tls9, for backward compatibility.

Global variables

_winnt - Windows major version. Value:

5 - XP/2003

6 - Vista/7/8

10 - Windows 10

 

_winver - Windows version. Value:

0x501 - XP (5.1)

0x502 - 2003 (5.2)

0x600 - Vista (6.0)

0x601 - Windows 7 (6.1)

0x602 - Windows 8 (6.2)

0x603 - Windows 8.1 (6.3)

0xA00 - Windows 10 (10.0)

 

_iever - Internet Explorer version. Value:

0x600 - IE 6

0x700 - IE 7

0x800 - IE 8

and so on.

 

These values are in hexadecimal format. To display a value in hexadecimal format, use code like this:

 

out "0x%X" _winver

 

_win64 (QM 2.2.0) - 0 on 32-bit Windows, 1 on 64-bit Windows. Note: QM is 32-bit, but runs on 64-bit Windows too. See also: IsWindow64Bit.

 

_unicode (QM 2.3.0) - Unicode mode. Nonzero if QM is running in Unicode mode (checked Options -> General -> Text: Unicode). It is equal to the default code page that is used with str.ansi and str.unicode, i.e. CP_ACP (0) in ANSI mode or CP_UTF8 (65001) in Unicode mode.

 

_portable (QM 2.3.5) - 1 if QM is running as portable app, 0 if not.

 

_hwndqm - QM main window handle. In exe it is handle of a hidden window that is created in the primary thread of the process (not the thread that executes the macro).

 

_hinst - program module handle (HMODULE or HINSTANCE).

 

_logfile - default log file used by LogFile. Default is "qm log.txt" in My Documents\My QM. In exe, default is "exename log.txt" in program's folder. You can change it.

 

_logfilesize - maximal size of log file used by LogFile. Default is 1 MB. You can change it.

 

_qmdir - QM path without filename. Ends with \. Same as expanded "$qm$\". In exe it is exe path. To get path with filename, use ExeFullPath.

 

_qmver_str - QM version string like "2.1.5". See also QMVER constant, below.

 

 

QM 2.3.2: All the global predefined variables except _logfile and _logfilesize are read-only.

Constants

QMVER - Quick Macros version. For example, 0x2010506 is 2.1.5.6.

 

EXE - 1 if compiling exe, 2 if qmm (macro that runs in separate process but not as separate exe file), 0 if the macro runs in QM.

 

WINNT, WINVER, IEVER - obsolete, instead use variables _winnt, _winver and _iever (see above). In macros running in QM these constants are the same as the variables. However in macros compiled to exe, the variables contain values for the computer where the program is running, whereas the constants have values for the computer where the program was compiled. Therefore it's better to use the variables, not constants. Also, in exe it's better to use them with if, not #if.

 

QM 2.3.3. QM defines constants for QM run-time errors. Names begin with ERR_ or ERRC_.

The error codes are in range 500-1999.