Quick start manual

4-10
Delphi Language Guide
Expressions
The following rules apply to string concatenation.
•The operands for + can be strings, packed strings (packed arrays of type Char), or
characters. However, if one operand is of type WideChar, the other operand must
be a long string (AnsiString or WideString).
The result of a + operation is compatible with any string type. However, if the
operands are both short strings or characters, and their combined length is greater
than 255, the result is truncated to the first 255 characters.
Pointer operators
The relational operators <, >, <=, and >= can take operands of type PChar and
PWideChar (see “Relational operators” on page 4-11). The following operators also
take pointers as operands. For more information about pointers, see “Pointers and
pointer types” on page 5-27.
The ^ operator dereferences a pointer. Its operand can be a pointer of any type except
the generic Pointer, which must be typecast before dereferencing.
P = Q is True just in case P and Q point to the same address; otherwise, P <> Q is True.
You can use the + and operators to increment and decrement the offset of a
character pointer. You can also use to calculate the difference between the offsets of
two character pointers. The following rules apply.
•If I is an integer and P is a character pointer, then P + I adds I to the address given
by P; that is, it returns a pointer to the address I characters after P. (The expression
I + P is equivalent to P + I.) P I subtracts I from the address given by P; that is, it
returns a pointer to the address I characters before P. This is true for PChar
pointers; for PWideChar pointers P + I adds SizeOf(WideChar) to P.
•If P and Q are both character pointers, then P Q computes the difference between
the address given by P (the higher address) and the address given by Q (the lower
address); that is, it returns an integer denoting the number of characters between P
and Q. P + Q is not defined.
Table 4.9 Character-pointer operators
Operator Operation Operand types Result type Example
+ pointer addition character pointer, integer character pointer P + I
- pointer subtraction character pointer, integer character pointer, integer P - Q
^ pointer dereference pointer base type of pointer P^
= equality pointer Boolean P = Q
<> inequality pointer Boolean P <> Q