Delphi Error – E2013 Type of expression must be INTEGER

Delphi Compiler Error

E2013 Type of expression must be INTEGER

Reason for the Error & Solution

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.

Share:

Leave A Reply

Your email address will not be published. Required fields are marked *

You May Also Like

Delphi Compiler Error E2313 Attribute – Known attribute cannot specify properties Reason for the Error & Solution No further information...
Delphi Compiler Error E2379 Virtual methods not allowed in record types Reason for the Error & Solution No further information...
Rodrigo , one of the long time Delphi Developer has been working on one of his personal project “Delphi IDE...