Inno Setup Preprocessor: #if, #elif, #else, #endif

Inno Setup Preprocessor

Inno Setup Preprocessor: #if, #elif, #else, #endif

Syntax

if-directive: if <expr>
elif-directive: elif <expr>
else-directive: else
endif-directive: endif

Description

The if, elif, else, and endif conditional directives control in- and exclusion of portions of script.

ISPP first evaluates the expressions following each if or elif directive until it finds one evaluating to non-zero. It then selects the portion of script following this directive up to its associated elif, else, or endif. Earlier portions which followed an if or elif which evaluated to zero, or which follows any next elif are not selected and thus not seen by the Inno Setup compiler.

If no expression evaluated to non-zero, the preprocessor selects the script portion after the else directive if present, else nothing is selected.

Finally, after selecting any script portion, ISPP preprocesses it too, so if it contains other preprocessor directives, ISPP carries out those directives as well.

Each if directive in a source file must be matched by a closing endif directive. Any number of elif directives can appear between the if and endif directives, but at most one else directive is allowed. The else directive, if present, must be the last directive before endif.

The if, elif, else, and endif directives can be nested. Each nested else, elif, or endif directive belongs to the closest preceding if directive.

Inline conditional directives may not be mixed with simple. If the if directive is simple (occupying a whole line), its associated directives (elif, else, or endif) must also be simple and not inline (appearing inside other lines).

Examples

#define Lang

[Tasks]
#if "English" == Lang = ReadIni(SetupSetting("MessagesFile"), \
  "LangOptions", "LanguageName")
  Description: "For all users"; Name: all
#elif "German" == Lang
  Description: "Fur alle"; Name: all
#else
# error Unsupported language
#endif