My original question was:

"Does anyone know how to get the number of element in a set and how to know
the value stored in first, second .. position of a set easily? I know we can
loop through the whole set, but is there any faster way?"

I don't think high(setname) works for a set. We maybe confuse 'set' and
'enumerated', don't we?

Jim Zheng

-----Original Message-----
Behalf Of Peter Hyde
Sent:   Friday, 19 February 1999 14:57
To:     Multiple recipients of list delphi
Subject:        RE: [DUG]:  about SET

Myles wrote:

> If you know the first value in a Set you could use a combination of ORD,
> and PRED
> Count := ORD( PRED( FirstValue )) - ORD( FirstValue)+ 1;
> You would probably have to use RTTI  to get the first element.

1. To this hot brain, that looks invalid -- pred(FirstValue) should
be undefined. Do you perhaps mean pred(ord(firstvalue))? Or
maybe I misunderstand what's needed, so ignore and read on.

2. I've forgotten the question so I may be at a disadvantage but:

a) If it's to find out the position in a list, won't simply ord(x) do?

b) If it's to find out the count won't  ord(high(setname))  do?

Mustn't forget the low() and high() operators, they can be really
handy in this kind of case...


Peter Hyde, SPIS Ltd, Christchurch, New Zealand
* TurboNote:
  -- small, FREE and very handy
* Print-to-Web automation
* Web design, automation and hosting specialists
Find all the above and MORE at
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]

    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]

Reply via email to