E2013 Type of expression must be INTEGER (Delphi)

From RAD Studio

Go Up to Error and Warning Messages (Delphi)

This error message is only given when the constant expression that specifies the number of characters in a string type is not of type integer.


program Produce;
type
  color = (red,green,blue);
var
  S3 : string[Succ(High(color))];
begin
end.

The example tries to specify the number of elements in a string as dependent on the maximum element of type color - unfortunately, the element count is of type color, which is illegal.


program Solve;
type
  color = (red,green,blue);
var
  S3 : string[ord(High(color))+1];
begin
end.