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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1a96e8174ef9f99 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-11-07 11:26:49 PST Path: archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed.stueberl.de!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 07 Nov 2003 13:26:47 -0600 Date: Fri, 07 Nov 2003 14:26:46 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Need Value of enum type not position. References: <686be06c.0311071027.79d6fa21@posting.google.com> In-Reply-To: <686be06c.0311071027.79d6fa21@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <5sWdnUsWT9tqbDaiRVn-uw@comcast.com> NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-6MyoZL2NEaDo25yAz5/4tpp7aB+4JqJVvJ8M38m9bZeyY2xzBMjUvnWbCt0feSYzB0hyNh3QmrX0NR9!h9mqtcHKXASZfeRWZRxIDu21uMbeuquRIl+sX+vzaWtsgMUdoeFIo4gI0IyMdA== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:2226 Date: 2003-11-07T14:26:46-05:00 List-Id: Daniel Allex wrote: > With the following declaration: > > type Hov_Mode_Type is > (INVALID, > OFF, > INITIATE, > AUTO); > for Hov_Mode_Type use( > INVALID => 7, > OFF => 8, > INITIATE => 9, > AUTO => 10); > > I can get the position > Ada.Text_IO.Put_Line(Integer'Image(Hov_Mode_Type'Pos(I))); > Which returns 0,1,2, or 3. What I want is the value of 7,8,9,10. I > can't get 'val to work. need some help. The ability to specify representations for enumeration types changes how the values are represented in hardware. The function 'Pos returns the position number, not the representation. If you want the representation, add also a 'Size clause, then do an Unchecked_Conversion to an appropriate integer type. For this particular case you could just declare a type with eleven values, and derive from it: type Hov_Base_Type is (HovO, Hov1, Hov2, Hov3, Hov4, Hov5, Hov6, Invalid, Off, Initiate, Auto); type Hov_Mode_Type is new Hov_Base_Type range Invalid..Auto; -- Robert I. Eachus 100% Ada, no bugs--the only way to create software.