Hi,

--- In [email protected], Micha� Wo�niak <[EMAIL PROTECTED]> wrote:
> 
> >  > Hmmm... wondering if you really tested your code...
> >  > doing a for loop is not the same as the foreach
> >  > construct (which is for collections). enumerated types
> >  > are actually integers and you can typecast back and
> >  > forth. so "for i := Low(TyourEnum) to High(TyourEnum)
> >  > do" will actually convert to "for i := 5 to 25 do"
> >
> >     I tried this code:
> >
> >     ... and it returns a result of 3, which is as I'd expect.
> 
> My mistake... Next time I will try to think faster than I write,
sorry for 
> that, folks.
> 
> Homo sum, nihil humane a me alienam esse puto.
> 
> Cheers
> Mike

   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.






-----------------------------------------------------
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