comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: Ada Enumerations
Date: 1997/12/04
Date: 1997-12-04T00:00:00+00:00	[thread overview]
Message-ID: <3486C057.6207@gsfc.nasa.gov> (raw)
In-Reply-To: 662cs9$b34$1@newman.pcisys.net


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




  parent reply	other threads:[~1997-12-04  0:00 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-12-03  0:00 Ada Enumerations Jeffrey Harris
1997-12-03  0:00 ` James S. Rogers
1997-12-03  0:00   ` Robert Dewar
1997-12-03  0:00     ` Stanley R. Allen
1997-12-04  0:00       ` Matthew Heaney
1997-12-04  0:00         ` Stanley R. Allen
1997-12-07  0:00           ` Keith Thompson
1997-12-07  0:00             ` Matthew Heaney
1997-12-07  0:00             ` Robert Dewar
1997-12-08  0:00               ` Keith Thompson
1997-12-07  0:00                 ` Matthew Heaney
1997-12-11  0:00                   ` John G. Volan
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-05  0:00         ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-08  0:00         ` GNAT'Object_Size Mats Weber
1997-12-10  0:00           ` GNAT'Object_Size Robert Dewar
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00       ` Ada Enumerations Robert Dewar
1997-12-04  0:00         ` Stanley R. Allen
1997-12-18  0:00           ` Wes Groleau
1997-12-04  0:00       ` GNAT'Object_Size Mats Weber
1997-12-04  0:00 ` Stephen Leake [this message]
1997-12-04  0:00   ` Ada Enumerations Matthew Heaney
1997-12-04  0:00     ` Robert Dewar
1997-12-06  0:00       ` Jean-Pierre Rosen
1997-12-06  0:00         ` Making Predefined Operators Abstract Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
1997-12-10  0:00 Ada enumerations Stanley R. Allen
1997-12-10  0:00 ` John M. Mills
1997-12-10  0:00 ` Robert Dewar
1997-12-11  0:00   ` Mats Weber
1997-12-11  0:00     ` Robert Dewar
1997-12-12  0:00       ` Mats Weber
1997-12-12  0:00         ` Robert Dewar
1997-12-12  0:00     ` Samuel T. Harris
1997-12-11  0:00   ` Stanley R. Allen
1997-12-12  0:00     ` Robert Dewar
replies disabled

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