comp.lang.ada
 help / color / mirror / Atom feed
From: mike@athome <mike_member@newsguy.com>
Subject: how to print position number of an enumeration variable?
Date: 29 Sep 2001 18:09:55 -0700
Date: 2001-09-29T18:09:55-07:00	[thread overview]
Message-ID: <9p5rd30202n@drn.newsguy.com> (raw)

hello,

suppose I have a variable of some enumeration type, and I want to
print or find the position number in the enumeration type that this
variable holds. How can do that?

for example:

-----------
with Ada.Text_Io; use Ada.Text_Io;

procedure Enum is
  type Day_type is (Monday, Tuesday, Wednesday, Thursday, 
                    Friday, Saturday, Sunday);

  Day Day_Type := Monday;

begin

   Put_Line("the position number of first enumeration elemenet is " & 
             Day_type'Image( ???? ) );

end Enum;

---------------

I know that the first enumeration literal will have a position of 0. But
I just wanted to see if one can print this value. I looked at the attributes
of scalar data types, and do not see something like S'pos ?

thanks,
mike




             reply	other threads:[~2001-09-30  1:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-09-30  1:09 mike [this message]
2001-09-30  2:31 ` how to print position number of an enumeration variable? DuckE
2001-09-30  5:37   ` mike
2001-09-30  6:27     ` James Rogers
2001-09-30 12:52       ` Robert Dewar
2001-10-02 17:49       ` Randy Brukardt
2001-09-30 12:50     ` Robert Dewar
2001-09-30 13:53       ` David Botton
replies disabled

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