Posted by Bill DelphiMan
In Reply to Enumerated types and incompatible type compile errors in Delphi 2007 posted by Warwick Weston Wright: I was recently writing code using a list of 10 enumerated constants the declaration had the following code:
: Type STTypes=(ST64BitInteger,.....);
: and the following line of code caused a compile time error 'incompatible types'
The compilation error has nothing to do with the fact that enumerated types are constants or not (well, they are
constants, but this irrelevant here).
If you want to compare two values of different types, then you have to at least convert one of them to another type. Only very occasionally this conversion is done automatically by the compiler, but in most cases you have to explicitly specify the conversion.
What should work, is the following:
if FrmNewTbl.FrmCreateNewTbl.CmbType.ItemIndex = Ord(ST64BitInteger) then ...
Ord() returns the "ordinality" of the enumerated value. By default, the ordinalities start from 0. When you declare for example:
type STTypes = (ST64BitInteger, STOther, STYetAnother,...);
then the ordinality of ST64BitInteger is 0, the ordinality of STOther is 1, and so on.