Delphi Programming/Boolean expression

A boolean expression returns a boolean value that can be used directly or stored in a boolean variable. An expression is created on a operator (and, or, xor, <, >...) which needs a given number of operands which can be a hard coded value, a variable or even another expression. A boolean expression can use boolean or numerical values:

Logical operators
The logical operators allow to handle and compare the boolean or binary data. If you are not familiar with this concept, learn more about the boolean algebra.

Operator "not"
The NOT logical operator is written  in Delphi. So to get the opposite of a value in Delphi, we write:

Operator "and"
The AND logical operator is written  in Delphi. It's like  in C. So to make a bitwise and on values in Delphi, we write:

Operator "or"
The OR logical operator is written  in Delphi. It's like  in C. So to make an or on values in Delphi, we write:

Operator "xor" (symmetric difference, or exclusive)
The XOR logical operator is written  in Delphi. So to make an xor on values in Delphi, we write:

Comparison operators
They are mostly used to do logical tests on numerical values.

Equality " = "
The Delphi equality comparator ' = allows to verify that the value on the left is strictly equal to the value on the right.

It is the same as do an inversion on the XOR logical operator (i.e. NOT XOR). Here is the truth table of the = comparator for the (x = y) operation:

Difference "<>"
The Delphi differential operator <> allows to verify that the value on the left is strictly different to the value on the right:

Comparator "<" (strictly less than) :
The comparator "<" (strictly less than) allows to verify that the value on the left is strictly less than to the value on the right. This operator returns true only if the numerical value is strictly less than to the numerical value on the right.

Comparator "<=" (less than) :
The comparator "<=" (less than) allows to verify that the value on the left is less than to the value on the right. This operator returns true only if the numerical value is less than to the numerical value on the right.

Comparator ">=" (greater than) :
The comparator ">=" (greater than) allows to verify that the value on the left is greater than the value on the right. This operator returns true only if the numerical value is greater than the numerical value on the right.

Comparator ">" (strictly greater than) :
The comparator ">" (strictly greater than) allows to verify that the value on the left is strictly greater than the value on the right. This operator returns true only if the numerical value is strictly greater than the numerical value on the right.

Expression combination
You can create a boolean expression on boolean expressions instead of variables:

A boolean expression on boolean expressions will use the returned values of the nested expressions. The nested expressions are in the brackets. They are evaluated first. In other word, if you change the brackets, the expressions will be evaluated differently:

So beware of the order.