comp.lang.ada
 help / color / mirror / Atom feed
From: Frode Tenneboe <ft@alne.edh.ericsson.se>
Subject: Re: array(enumeration)
Date: 2000/07/20
Date: 2000-07-20T00:00:00+00:00	[thread overview]
Message-ID: <964097130.804601@edh3> (raw)
In-Reply-To: Pine.LNX.4.10.10007191643160.863-100000@lexis.di.fct.unl.pt

Mario Amado Alves <maa@di.fct.unl.pt> wrote:
: How do I define an array type indexed by an enumeration type?

:   type Array_Type is array(<>) of Some_Type;
:     --                    /|\
:     --                     |
:     -- compiler says identifier expected here

It is. You have to give the discrete type otherwise integer is assumed.

Try:

with Text_Io;

procedure Enum is

   type Month is (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec);
   type Array_Type is array(Month range <>) of Integer;

   Spring : Array_Type(Mar..May) := (Mar => 31, Apr => 30, May =>31);

begin
   Text_Io.Put_Line(Month'Image(Spring'First)& " has "& Integer'Image(Spring(Spring'First))& " days.");

end Enum;

: This makes sense to me, but does not compile. So how do I code the idea?

Does this make more sense?

 -Frode
-- 
^ Frode Tenneb�                    | email: ft@edh.ericsson.se      ^
| Ericsson Radar AS. N-1788 Halden |                                |
| Phone: +47 69 21 41 47           | Frode@IRC                      |
| with Standard.Disclaimer; use Standard.Disclaimer;                |




      parent reply	other threads:[~2000-07-20  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-19  0:00 array(enumeration) Mario Amado Alves
2000-07-20  0:00 ` array(enumeration) Philip Anderson
2000-07-20  0:00 ` array(enumeration) Steve Folly
2000-07-20  0:00 ` Frode Tenneboe [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox