From: Colin Fraser [mailto:[EMAIL PROTECTED]]
> Thanks, that did it, I was casting to an integer (which works for
enumerated
> types) and not to a Byte...
>
> The Byte did the trick...
Be careful. If you add more elements to your type, byte might need to
become word, or integer or something even bigger. There's more to this than
meets the eye. The size of the set type changes in relation to the number
of elements in the set range:
type
TSet1 = set of 1..7;
TSet2 = set of 1..15;
TSet3 = set of 1..23;
TSet4 = set of 1..31;
TSet5 = set of 1..39;
procedure TForm1.Button1Click(Sender: TObject);
begin
showmessage(inttostr(sizeof(tset1))); // 1..7 = 1 byte = type Byte
showmessage(inttostr(sizeof(tset2))); // 8..15 = 2 bytes = type Word
showmessage(inttostr(sizeof(tset3))); // 17..23 = 4 bytes (!) = type
LongWord
showmessage(inttostr(sizeof(tset4))); // 24..31 = 4 bytes = type LongWord
showmessage(inttostr(sizeof(tset5))); // 32..39 = 5 bytes = Now what?
end;
Fortunately the compiler will tell you if you got it wrong, but Neven's
suggestion is better, as it's more maintainable.
Cheers,
Carl
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"