Relational Operator Precedence

InstallShield 2020 » InstallScript Language Reference

Relational operators have an overall lower precedence than arithmetic operators. This means that InstallShield performs all arithmetic operations before beginning to evaluate logical operations. Logical expressions are evaluated from left to right, unless the order of operations is modified by parentheses. Among relational operators the order of precedence is as follows:

First, less than ( < ), less than or equal to ( <= ), greater than ( > ), and greater than or equal to ( >= ).
Then, equal to ( = ) and not equal to ( != ).

Therefore, when combining arithmetic and relational expressions, the InstallShield Script Compiler evaluates precedence in the following order:

1. Negative (minus) unary.
2. Multiplication and division.
3. Addition and subtraction.
4. Less than ( < ), less than or equal to ( <= ), greater than ( > ), and greater than or equal to ( >= ).
5. Equal to ( = ) and not equal to ( != ).

In the expression 6 + 7 > y, the InstallScript compiler adds 6 and 7 together and then compares the result (13) to y. To change the order of precedence, use parentheses. For example, in the expression 6 + (7 > y), the InstallScript compiler first determines if 7 is greater than y. If it is, then 1 (the numeric value of TRUE) is added to 6. If it is not, then 0 (the numeric value of FALSE) is added to 6.

When a statement contains arithmetic, relational, and logical operators, the compiler evaluates precedence in the following order:

1. Negative (minus) unary has first precedence.
2. Multiplication and division have second precedence.
3. Addition and subtraction have third precedence.
4. NOT ( ! ) has fourth precedence.
5. Less than ( < ), less than or equal to ( <= ), greater than ( > ), and greater than or equal to ( >= ) have fifth precedence.
6. Equal to ( = ) and not equal to ( != ) have sixth precedence.
7. AND ( &&) has seventh precedence.
8. OR ( || ) has eighth precedence.

Use logical operators in if and while statements the same way you used relational operators. The example below adds nExampleSize and nHelpSize if bInstallExample and bInstallHelp are true.

    if (bInstallExample && bInstallHelp) then

        nTotalSize = nExampleSize + nHelpSize;

    endif;

The next example sets bPublicFile to TRUE if either bInstallProgram1 or bInstallProgram2 is TRUE.

    if (bInstallProgram1 || bInstallProgram2) then

        bPublicFile = TRUE;

    endif;

Note:You cannot use the && or || operators within an argument to a function. Instead, follow the above example and assign the value of the logical expression to a Boolean variable and then call the function with the variable as an argument.