Show: Object Pascal C++
Display Preferences

E2056 String literals may have at most 255 elements (Object Pascal)

From Appmethod Topics
Jump to: navigation, search

Go Up to Error and Warning Messages (Object Pascal) Index

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;
  LongString : string[256];  (*<-- Error message here*)

In the example above, the length of the string is just one beyond the limit.

program Solve;
  LongString : AnsiString;

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.

Personal tools
In other languages