Predefined variables

Predefined 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.

 

_dir, _findt, _findl, _gett, _getl are used by corresponding functions.

 

this - reference to object (variable) for which current member-function is called.

Predefined thread variables

You can use 10 predefined int variables tls0 ... tls9, that have thread scope. They are located in thread local-storage memory as array. QM does not use them.

 

Other variables are populated by QM, and you also can use them:

 

_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 success code. 0 and positive values indicate success or partial success; negative values indicate error.

 

_error - error info.

 

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

 

0 (default) - depends on context. In most cases - primary monitor. If dialog owner window specified - owner's monitor. With ShowDialog, also depends on dialog style.

1-30 - monitor index.

-1 - monitor from mouse.

-2 - monitor from active window.

-3 - primary monitor.

Or can be handle of a window whose monitor must be used.

If _monitor's value is invalid (invalid index, handle, etc), is used the primary monitor.

 

_monitor is applied to these functions: mes, list, inp, inpp, OnScreenDisplay, ShowDialog, and most functions that use them. Some other functions either have a monitor argument 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

 

Predefined global variables

_winnt - Windows NT major version. Type - int. Value:

0 - non-NT OS (98/Me). Obsolete. QM 2.3.0 and later versions don't run on these OS.

5 - 2000/XP/2003

6 - Vista

 

_winver - Windows version. Type - int. Value:

0x40A - 98 (4.10). Obsolete. QM 2.3.0 and later versions don't run on these OS.
0x45A - Me (4.90). Obsolete. QM 2.3.0 and later versions don't run on these OS.
0x500 - 2000 (5.0)
0x501 - XP (5.1)
0x502 - 2003 (5.2)

0x600 - Vista (6.0)


_iever - Internet Explorer version. Type - int. Value:

0x500 - IE 5

0x532 - IE 5.50

0x600 - IE 6

0x700 - IE 7

 

QM also defines constants WINNT, WINVER and IEVER. In macros running in QM they have the same values as _winnt, _winver and _iever. 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. In macros that will be compiled to exe and distributed, consider using variables (not constants) and if (not #if).

 

_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.

 

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

 

_hinst - qm.exe module handle (HMODULE or HINSTANCE). In exe it is handle of the exe file. If you need module handle (or instance handle, which is the same) to use with API resource functions that will be used in exe, instead use GetExeResHandle, which also allows you to use these resources when debugging (when the macro runs in QM, not as exe).

 

_dialogicon - default dialog icon handle (HICON). In exe it is program's icon.

 

_hfont - dialog font handle (HFONT).

 

_logfile - default log file used by LogFile. In QM, 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. Type - str.

 

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

 

_qmdir - QM path without filename. Ends with \. In exe it is exe path. Same as expanded $qm$\. Type - str. To get path with filename, use this code:

 

str mypath.fix(GetModuleFileName(0 mypath.all(300) 300))

 

_qmver_str - QM version string (QMVER as string). Type - str.

 

These variables are declared and populated by QM. In QM 2.1.8 and older, they were declared in the System folder. You should not modify them, except _dialogicon, _hfont, _logfile and _logfilesize. If you replace _dialogicon or _hfont, do not destroy default icon/font objects; QM will not destroy new objects.

 

See also: more types of storage predefined constants make exe