12.8.4 String operators

There is only one string operator: +. Its action is to concatenate the contents of the two strings (or characters) it acts on. One cannot use + to concatenate null-terminated (PChar) strings. The following are valid string operations:

  'This is ' + 'VERY ' + 'easy !'
  Dirname+'\'

The following is not:

Var
  Dirname : PChar;
...
  Dirname := Dirname+'\';

Because Dirname is a null-terminated string.

Note that if all strings in a string expressions are short strings, the resulting string is also a short string. Thus, a truncation may occur: there is no automatic upscaling to ansistring.

If all strings in a string expression are ansistrings, then the result is an ansistring.

If the expression contains a mix of ansistrings and shortstrings, the result is an ansistring.

The value of the {$H} switch can be used to control the type of constant strings; by default, they are short strings (and thus limited to 255 characters).