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-----
From:   [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On
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...


cheers,
peter

==================================================
Peter Hyde, SPIS Ltd, Christchurch, New Zealand
* TurboNote: http://TurboPress.com/tbnote.htm
  -- small, FREE and very handy
* Print-to-Web automation http://TurboPress.com
* Web design, automation and hosting specialists
Find all the above and MORE at http://www.spis.co.nz
---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to