From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a415d3a613d86a4e X-Google-Attributes: gid103376,public From: Stephen Leake Subject: Re: Ada Enumerations Date: 1997/12/04 Message-ID: <3486C057.6207@gsfc.nasa.gov>#1/1 X-Deja-AN: 295121993 References: <662cs9$b34$1@newman.pcisys.net> Organization: NASA Goddard Space Flight Center -- Greenbelt, Maryland USA Reply-To: Stephen.Leake@gsfc.nasa.gov Newsgroups: comp.lang.ada Date: 1997-12-04T00:00:00+00:00 List-Id: Jeffrey Harris wrote: > > I have created an Ada Enumeration called DataTypes, afterwards I've created a > 'use' clause where I give each element an integer value. The last Enumeration > is LASTTYPE and is given a value of 100. > > Now to the problem. I'd like to be able to do something like the following.. > > NewLocation: Integer := DataTypes.LASTTYPE + 1; -- Newlocation = 101 It looks like you should use an integer type for DataTypes, rather than an enumeration type. Take a step back, and consider why you are doing this in the first place. If you post a discription of your broader problem, maybe we could give some better advice. > > The compiler isn't letting me do this. I've tried to use 'value, 'pos, and > 'val to no avail, how do I convert an Ada enumerated type into an integer value? If you really, really need to do this, GNAT provides the non-standard attribute 'Enum_Rep, which gives you the integer you specified for the enumeration literal. ObjectAda does not provide this attribute - I don't know about other compilers. You can use Unchecked_Conversion to get the same result. > > Thanx... Please e-mail me at harris@pcisys.net > > Jeff Harris -- - Stephe