>Yes, I can use an array, but I don't like it here. Actually I use the set as
>a parameter for passing the values to a function, and most time I need only
>one or two values to be passed. Only occasionally pass more values. So in
>most time I have to ignore all other values or giving the dumb values except
>one or two that I need. The program will look ugly. Don't you think so?
During the weekend I wrote a small class (really small) to encapsulate the
Upper, Lower and Count of a set... You would need to create a class for each
enumeration
as it stands and is therefore a perfect example of why I'd like to see templates
implemented
in pascal... If anyone wants the class and example project (4k zip) personal email me
and
I'll send it... It's so simple I don't know if it's worth cluttering the delphi FTP...
Example:
procedure TForm1.CheckBox1Click(Sender: TObject);
var
I : TEnumElements;
begin
with Sender as TCheckboc do
if Checked then SE.Contents :=SE.Contents+[TEnumElements(Tag)]
else SE.Contents :=SE.Contents-[TEnumElements(Tag)];
Caption := '';
for I := SE.Lower to SE.Upper do begin
if I in SE.Contents then Caption := Caption + Names[I]+' ';
end;
end;
I'm tempted to implement the set internally as a dynamic array so that NEXT
and PRED can be used... and offer a .AsSet property instead on the contents
which constructs the set from the array...
--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz