if

InstallShield 2019 » InstallScript Language Reference

Use an if statement when you want your script to choose between two or more options. An if statement consists of the keyword if, a condition to be evaluated, the keyword then, and the keyword endif followed by a semicolon, as shown below:

if (condition) then

    // statements to be executed if condition is true

endif;

The condition can be one of the following:

A Boolean or integer constant, variable or literal.
An expression that produces a Boolean or integer result.
A function that returns an integer result.

The parentheses around the condition are optional, but highly recommended for readability.

Tip • Many InstallScript functions return a negative value when they fail. When using the result of InstallScript functions as the condition in an if statement, test for failure by using a statement like the one below:

    if (FunctionA (ParameterOne) < 0) then

        // Statements to handle the failure

    else

        // Statements when the function succeeds

    endif;

InstallScript provides the following if statement structures:

if Structure with goto
if-then Structure
if-then-else Structure
Nested if-then-else Structure
elseif Structure