Inno Setup Preprocessor: User Defined Macros

You can define so called "macros" in your scripts, these can be thought of as "user defined functions."

Macro declaration consists of formal parameter list and expression. That expression is evaluated when macro is called (see below). The result of the macro call is the result of the macro expression. Macro expression can contain parameter names, they are treated as usual variables.

The formal syntax of macro declaration is provided in define and the ISPPBuiltins.iss file contains many example macros.

Please note that there must be no space between macro name and opening parenthesis.

Actual parameters for parameters declared as by-reference must be modifiable l-values (in other words, other defined variables or expressions that evaluate to l-values). If macro expression modifies by-reference parameter, the variable that is passed as this parameter gets modified. By-value parameters can also be modified by macro expression (using assignment operators), but this modification doesn't affect the value of a variable which could be passed as this parameter.

Though macro can only contain one expression, it can be used as full featured user defined function, because ISPP supports sequential evaluation operator (comma), assignment operators (simple and compound) and conditional operator (?:).

See also