HomeDelphiDelphi Error – E2013 Type of expression must be INTEGER

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 X2421 Imported identifier ‘%s’ conflicts with ‘%s’ in ‘%s’ Reason for the Error & Solution This occurs...
Delphi Compiler Error X2367 Case of property accessor method %s.%s should be %s.%s Reason for the Error & Solution No...
Delphi Compiler Error X2269 Overriding virtual method ‘%s.%s’ has lower visibility (%s) than base class ‘%s’ (%s) Reason for the...