Define variable type

Syntax (simplified)

type typename members


Members can be in the same line or/and in multiple lines:


type typename


Instead of the type keyword, you can use class or category.



typename - name of the new type.

members - list of members.



QM has 7 intrinsic variable types - int, byte, word, long, double, lpstr and str. It also defines 7 OLE types and several other types. You can combine variables of several different types to create user-defined types (also known as structures or records). User-defined types are useful when you want to create a single variable that contains several related pieces of information. You create a user-defined type with the type statement. Once you have new type defined, you can create variables of that type (typename) like variables of intrinsic types. The type definition exists until QM exits or other file is opened.


A user-defined type can contain member variables of any type, including other user-defined types.


A user-defined type can contain embedded single-dimension arrays. The number of elements must be enclosed in square brackets and immediately follow member name: [membertype]membername[numelem]. Embedded strings (not lpstr or str) must be declared as byte array. Such array cannot be used directly as lpstr or pointer. Instead, use & operator to get address of array, and assign it to a lpstr or pointer variable. Example: lpstr s = &var.array. Array name, when used without [], means first element.


It is possible to specify nonstandard member alignment, member offsets (e.g. to define unions), and define anonymous types within types. Read more here.


It is possible to use a base type (inheritance).


It is possible to add global identifiers. Usually it is used to define a category. Syntax:


type typename [members] [: globals]


User-defined types also can be defined in reference files and type libraries, which allows you to use them without defining explicitly. Many declarations are in WINAPI and WINAPIV reference files. Usage example:




Some Windows types are defined by default. Some of them are defined by QM, others in the System\Declarations folder.


Some Windows types actually are not user-defined types, but rather aliases of other types or of pointers to other types. For example, instead of various handle types (HWND, HANDLE, HMODULE, HICON, etc), in QM is used int. Instead of various pointer types (usually LPTYPENAME), use TYPENAME*. Instead of string types (LPSTR, etc), use lpstr.


QM 2.3.0. Allowed comments. See example. Also can contain lines containing only comments, but the comments must always begin with ;;.


See also: usage unions classes categories declarations scope



type RECT left top right bottom
type PAINTSTRUCT hdc fErase RECT'rcPaint fRestore fIncUpd !r[32]
type MY @w !b ~s i[4] ~*sp RECT*rp[10]
type MY2 word'w byte'b str's int'i[4] str*sp RECT*rp[10]
type MY3 ;;the same as above, but in multiple lines
	word'w byte'b str's ;;the same as @w !b ~s
	int'i[4] ;;embedded array
	str*sp ;;pointer
	RECT*rp[10] ;;embedded array (10 pointers)
type ARR2 ARRAY(str)a ARRAY(int)b