Delphi Error – E2001 Ordinal type required

Delphi Compiler Error

E2001 Ordinal type required

Reason for the Error & Solution

The compiler required an ordinal type at this point. Ordinal types are the predefined types Integer, Char, WideChar, Boolean, and declared enumerated types.

Ordinal types are required in several different situations:

  • The index type of an array must be ordinal.
  • The low and high bounds of a subrange type must be constant expressions of ordinal type.
  • The element type of a set must be an ordinal type.
  • The selection expression of a case statement must be of ordinal type.
  • The first argument to the standard procedures Inc and Dec must be a variable of either ordinal or pointer type.

program Produce;
type
  TByteSet = set of 0..7;
var
  BitCount: array [TByteSet] of Integer;
begin
end.

The index type of an array must be an ordinal type – type TByteSet is a set, not an ordinal.

program Solve;
type
  TByteSet = set of 0..7;
var
  BitCount: array [Byte] of Integer;
begin
end.

Supply an ordinal type as the array index type.

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...