You should study the use of enumerated types well before implementing
it... as stated before in this thread having enumerated types with
sequential ord will raise no problem

Using "High(TMyType) - Low(TMyType) + 1" to get the count for the following
types will work without any problem

    TMyType = (enum1, enum2, enum3) or
    TMyType = (enum1 = 0, enum2 = 1, enum3 = 2) or
    TMyType = (enum1 = 123, enum2 = 124, enum3 = 125)

If you are obliged to use a type similar to
(myConst1, myConst2, myConst3= 99, myConst4, myConst5 = 666)
I suggest you define their total number in another constant, those are never
going to change at run time, the only way they can be modified is by the
developper at design time.
This might not be the best of solutions but it would work

Regards
Vahan

-----Original Message-----
From: Jonathan Mora [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 22, 2005 3:33 AM


Good pick. Anyway, we're just discussing other
possibilities here. The (myConst1, myConst2, myConst3
= 99, myConst4, myConst5 = 666) construct was just
borrowed from C++ to maintain code transparency
between the 2 languages. IIRC, it was introduced in
Delphi 6.


> --- "Peter W." <[EMAIL PROTECTED]> wrote:
>    Actually, I was trying out something this
> morning, and I think that
> I prefer this solution:
>
> function Test2 : integer;
> type
>   TMyType = (enum1, enum2, enum3);
> begin
>   Result := Ord(High(TMyType)) - Ord(Low(TMyType)) +
> 1;
> end;
>
>    ... since there is not looping involved.
>
>    ... although technically Ord(Low(TMyType)) is
> zero, so, you could
> simply use:
>
>   Result := Ord(High(TMyType)) + 1;
>
>   ... even simpler!!!
>
> Regards,
>       Peter W. :-)))
> Sandy Bay, Hobart, Tas, AU.
>
>
>
>
>

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]


      Yahoo! Groups Sponsor
            ADVERTISEMENT





----------------------------------------------------------------------------
----
Yahoo! Groups Links

  a.. To visit your group on the web, go to:
  http://groups.yahoo.com/group/delphi-en/

  b.. To unsubscribe from this group, send an email to:
  [EMAIL PROTECTED]

  c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




[Non-text portions of this message have been removed]



-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED] 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/delphi-en/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to