comp.lang.ada
 help / color / mirror / Atom feed
From: "David C. Hoos, Sr." <david.c.hoos.sr@ada95.com>
Subject: Re: Get Integer into Enumeration_IO doesn't work
Date: Sat, 16 Nov 2002 05:13:07 -0600
Date: 2002-11-16T05:13:07-06:00	[thread overview]
Message-ID: <mailman.1037445242.21003.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: b740187a.0211160217.658dc54@posting.google.com

Why are you using Enumeration_IO to read numbers?

Enumerations are types like this:
type Color is (Red, Orange, Yellow, Green, Blue, Purple);

Then, an Enumeration_IO package instantiated for the type
Color would read the string "orange", and translate it to
the  Orange enumeration value which is represented in memory
by the binary number 1. (0 for red, 2 for yellow, etc.).

To input and output integers, you should use an instantiation
of Ada.Text_IO.Integer_IO.
 
----- Original Message ----- 
From: "Amir Shaked" <amir.shaked@ca.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: November 16, 2002 4:17 AM
Subject: Get Integer into Enumeration_IO doesn't work


> Hello,
> 
> The following code compiles and links
> but fails on DATA_ERROR in run-time.
> Can you tell me why?
> 
> with Text_IO;
> procedure PrintInt
> is
>    Num  : Integer;
>    package EnumIO is new Text_IO.Enumeration_IO(Integer);
> begin
>    Text_IO.Put_Line ("Enter Num:");
>    EnumIO.Get (Num);
> end PrintInt;
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
> 
> 




  reply	other threads:[~2002-11-16 11:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-16 10:17 Get Integer into Enumeration_IO doesn't work Amir Shaked
2002-11-16 11:13 ` David C. Hoos, Sr. [this message]
2002-11-17  8:38 ` Dr. Michael Paus
  -- strict thread matches above, loose matches on Subject: below --
2002-11-18  6:38 Grein, Christoph
2002-11-18 14:28 ` Peter Richtmyer
replies disabled

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