Syntax of QM macro code

QM macro text is a sequence of statements. Usually, a statement is a single line of code that performs some operation or declares some identifier. Examples:


lef+ 10 200 "Notepad"
int a b c
a = b * 100
Func b 1
a = Func(b 1)


The first and second statements are macro commands. They consist of the following parts:


The third statement declares variables a, b and c.


The fourth statement assigns expression b*100 to variable a.


In the fifth statement, is called function Func with arguments b and 1.


In the last statement, is called function Func, and its return value is assigned to variable a.


10, 200, 100 and 1 are numeric constants.

"Notepad" is string constant.

= and * are operators.


Parts of statements must be separated with spaces (except command/option). In statements with operators (example 4), spaces may be omitted. To separate arguments, also can be used commas (,).


The list of arguments must be enclosed (example 6), but if function name begins the statement (examples 1 and 5), it is not necessary. With enclosed arguments, the ( must be immediately after function name and option character (if any).


Some characters at the beginning of a line have special meaning:


Space, ;, /, or \ disables the line. This can be used for comments. To easier disable/enable a line (or several selected lines), right click the selection bar. Comments also can follow a statement. For such comments use ;;.


Tabs or commas are used with flow-control statements (if, rep, etc). Example:


 if a is less than 10, left-click, else exit
if a<10
	a + 1 ;;increment a
else ret


A single line can contain several statements separated by semicolon (;). Semicolon is optional after a statement that begins with command/function name and has enclosed arguments (or empty parentheses). Semicolon also is optional after else, err and case. Examples:


lef+ 10 100 Notepad; lef; int a; a = b + 100; Func(a b); b = Func(a b)
rep() if(b>a) b=Func(a b); else break

Syntax descriptions used in this Help file

Gray symbols have the following meaning:

[a] a is optional.
a|b a or b.
a&b a and/or b.
(a b)|(c d) a b or c d.
(space)a before a must be space or semicolon.
(tab)a before a must be tab or comma.
... more parameters or statements.
int a a is function; it returns a value of type int.


Syntax description example:


lef[+|-] [x y] [window] [client]


In the example, all parameters are enclosed in []. It means that you can use 0, 1, 2, 3 or 4 arguments with the command.

The [+|-] means that you can optionally use option character + or -.

The lef keyword in the example is at the beginning. It means that the lef command does not return a value and cannot be used as function.


Real code examples based on the above syntax description:


lef 10 200 "Notepad"
lef+ 10 200