From: Mark Lorenzen <mark.lorenzen@gmail.com>
Subject: Re: Problem with Position of the enumeration Type
Date: Wed, 23 Jan 2019 03:32:47 -0800 (PST)
Date: 2019-01-23T03:32:47-08:00 [thread overview]
Message-ID: <dfb6d62f-ffc0-4228-9fed-4e4c3aeabdac@googlegroups.com> (raw)
In-Reply-To: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com>
On Wednesday, January 23, 2019 at 11:06:01 AM UTC+1, Luis Ladron de Guevara Moreno wrote:
> Hello,
>
> I have an issue with the declaration of the enumeration type, when i try to map the values of an enumeration to a specific position.
>
> the code:
>
> procedure EnumerationTest is
>
> Position : Integer;
>
> type E_Test is (Pos10, Pos11, Pos12, Pos13, Pos14);
>
> for E_Test use (Pos10 => 10,
> Pos11 => 11,
> Pos12 => 12,
> Pos13 => 13,
> Pos14 => 14);
>
> begin
>
> for I in E_Test'Base loop
>
> Position := E_Test'pos (I);
> ada.Text_IO.Put (" Position: " & Position'Img & " Value: " & I'Img);
> end loop;
>
> end EnumerationTest;
>
> i thought that the result of the position was 10, 11, 12, 13, 14. But When i run this code, the result is 0, 1, 2, 3. I don't know what it is the exactly meaning of:
>
> for E_Test use (Pos10 => 10,
> Pos11 => 11,
> Pos12 => 12,
> Pos13 => 13,
> Pos14 => 14);
>
> and how can i assign a different position for the specific value.
> Could anyone help me with this problem?
>
> Thank you so much =)
What problem are you trying to solve? Defining the representation of enumeration values is normally only useful when doing I/O i.e. when you need to map an integer value to an enumeration value.
Regards,
Mark L
next prev parent reply other threads:[~2019-01-23 11:32 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-23 10:05 Problem with Position of the enumeration Type Luis Ladron de Guevara Moreno
2019-01-23 10:33 ` AdaMagica
2019-01-23 10:55 ` AdaMagica
2019-01-23 12:08 ` Luis Ladron de Guevara Moreno
2019-01-23 12:15 ` Karl Müller
2019-01-23 21:50 ` Niklas Holsti
2019-01-24 8:06 ` AdaMagica
2019-01-23 11:32 ` Mark Lorenzen [this message]
2019-01-23 12:30 ` Luis Ladron de Guevara Moreno
2019-01-23 20:22 ` Shark8
2019-01-24 8:13 ` AdaMagica
2019-01-23 17:06 ` Simon Wright
2019-01-23 22:54 ` Randy Brukardt
2019-01-23 23:47 ` Keith Thompson
2019-01-24 4:34 ` Keith Thompson
2019-01-24 9:11 ` Simon Wright
2019-01-24 21:41 ` Randy Brukardt
2019-01-23 21:42 ` Niklas Holsti
2019-01-23 22:35 ` Simon Wright
2019-01-23 23:20 ` Niklas Holsti
2019-01-24 16:43 ` Jeffrey R. Carter
2019-01-24 19:39 ` Niklas Holsti
2019-01-24 20:29 ` Jeffrey R. Carter
2019-01-24 21:43 ` Randy Brukardt
2019-01-26 9:44 ` G.B.
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox