Delphi Compiler Error
E2056 String literals may have at most 255 elements
Reason for the Error & Solution
This error message occurs when you declare a string type with more than 255 elements, if you assign a string literal of more than 255 characters to a variable of type ShortString, or when you have more than 255 characters in a single character string.
Note that you can construct long string literals spanning more than one line by using the ‘+’ operator to concatenate several string literals.
program Produce; var LongString : string[256]; (*<-- Error message here*) begin end.
In the example above, the length of the string is just one beyond the limit.
program Solve; var LongString : AnsiString; begin end.
The most convenient solution is to use the new long strings – then you don’t even have to spend any time thinking about what a reasonable maximum length would be.