Relational Operators (<, >, =, <=, >=, !=)
InstallShield 2020 » InstallScript Language Reference
Relational operators compare one expression to another within the context of a conditional statement, such as an if or while statement. For example, the following statement asks “Is x greater than 20?”:
if (x > 20) then
The answer to the questions can be only TRUE (1) or FALSE (0). The InstallScript compiler recognizes the relational operators listed in the table below:
Symbol |
Operation |
Example |
Description |
= |
Equal |
x = y |
True if x is equal to y. |
> |
Greater than |
x > y |
True if x is greater than y. |
< |
Less than |
x < y |
True if x is less than y. |
>= |
Greater than or equal to |
x >= y |
True if x is greater than or equal to y. |
<= |
Less than or equal to |
x <= y |
True if x is less than or equal to y. |
!= |
Not equal to |
x != y |
True if x is not equal to y. |
When you use a relational operator in an if...else statement, the program will follow one of two actions:
• | If the expression is TRUE, statements that follow the if are executed. Statements that follow the else are not executed. |
• | If the expression is FALSE, statements that follow the if are not executed. Statements that follow the else are executed. |
Relational operators have an overall lower precedence than arithmetic operators. Among just relational operators, less than, less than or equal to, greater than, and greater than or equal to have precedence over equal and not equal.
Caution:You cannot use assignment and relational operators in the same conditional expression. For example, the following will fail:
if ((listID = ListCreate (NUMBERLIST)) = LIST_NULL) then . . . endif;
Tip:Unlike C, which uses == to test for equality, InstallScript's assignment operator and relational operator use the same symbol ( = ).