[fpc-devel] TShiftState as enum

Marco van de Voort marcov at stack.nl
Thu Feb 17 08:37:40 CET 2005


> TShiftState is defined as TShiftState = set of (...);
> 
> How can I iterate through the enums? If not, can we split and add an
> enum:
> 
> TShiftStateEnum = (...)
> TShiftState = set of TShiftStateEnum;
> 
> ?

Of course that is possible. It requires some imagination though (and a feel
for obfuscated Pascal)



type myset = set of ( a1,a2,a3,a4,a5,a6);

// workaround types
const
     beginmyset=ord(low(myset));
     endmyset=ord(high(myset));
type
     uglyenum = beginmyset..endmyset;
     uglyset= set of uglyenum;

var b : myset;
    i : integer;

begin
  b:=[a1,a2,a3];
  for i:=ord(low(myset)) to ord(high(myset)) do
    if i in uglyset(b) then writeln(i);
end.









More information about the fpc-devel mailing list