Variables are used to temporarily store numbers, text and other data. The data can be changed. Variables can be passed to macro commands and functions as arguments.
Before using a variable, need to declare it (except predefined variables). Variable declaration includes type and name. The mostly used variable types are int (for numeric integer values), str (for strings) and double (for numeric floating-point values). Name can consist of characters A-Z, a-z, 0-9 and _, and cannot begin with a digit. In the following example, we declare variable i of type int, variable S3 of type str, and variable _a of type double. Then we assign some values:
int i; str S3; double _a i=5 S3="text" _a=15.477
QM has 7 intrinsic variable types: byte, word, int, long, double, lpstr, str. QM also has 7 OLE-Automation variable types (including arrays) and defines several other types. More types can be defined with type, class and interface statements, or in type libraries. The table shows properties of intrinsic variable types, and how they are related to C++ and C# variable types:
|Size (bytes)||1||2||4||8||8||4||16 + string|
|Max||255||65535||2147483647||2^63 - 1|
|C#||byte||ushort||int||long||double||similar to string|
The picture shows how variables of different types are stored in memory. Green squares represent bytes occupied by a variable of the specified type.
See also: declaration storage and scope more types of storage predefined variables user-defined types strings OLE types and other predefined types safe arrays conversions, etc.
Usage: expressions operators functions strings pointers