12.8.6 Relational operators

The relational operators are listed in table (12.7)

Table 12.7: Relational operators


= Equal
<> Not equal
< Strictly less than
> Strictly greater than
<= Less than or equal
>= Greater than or equal
in Element of

Normally, left and right operands must be of the same type. There are some notable exceptions, where the compiler can handle mixed expressions:

  1. Integer and real types can be mixed in relational expressions.
  2. If the operator is overloaded, and an overloaded version exists whose arguments types match the types in the expression.
  3. Short-, Ansi- and widestring types can be mixed.

Comparing strings is done on the basis of their character code representation.

When comparing pointers, the addresses to which they point are compared. This also is true for PChar type pointers. To compare the strings the PChar point to, the StrComp function from the strings unit must be used. The in returns True if the left operand (which must have the same ordinal type as the set type, and which must be in the range 0..255) is an element of the set which is the right operand, otherwise it returns False.