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.