comp.lang.ada
 help / color / mirror / Atom feed
From: Amal Kurian <kurian.amal@t-online.de>
Subject: Re: input/output exceptions
Date: 2000/11/18
Date: 2000-11-18T00:00:00+00:00	[thread overview]
Message-ID: <8v6lfe$rc7$07$1@news.t-online.com> (raw)
In-Reply-To: ApzR5.44026$U46.1356606@news1.sttls1.wa.home.com

While Robert Dewar pointed out, that 2.54 contains 2 and "junk" he should 
also have stated that since 2.54 is the last value to be read in, Ada 
ignores the junk and the program finishes while it couldn't ignore it if 
there is still something to be read in. Because a string consists of "junk" 
only ;) an exception is always raised.
To illustrate this, consider the modificated procedure:


with Ada.Integer_Text_IO, Ada.Float_Text_IO;
use Ada.Integer_Text_IO, Ada.Float_Text_IO;

procedure Test_Type_IO is

        First   : Integer       := 0;
        Second  : Float         := 0.0;
        

begin

        Get(First);
        Get(Second);
        
        Put(First);
        Put(Second);
        
end Test_Type_IO;


and the following values:


2.54
          2 5.40000E-01



Obviously the ignored "junk" from 2.54, that is 0.54, is a perfect float 
and is therefore assigned to 'Second'.

Kind regards,
Amal Kurian




DuckE wrote:

> 
> "Amal Kurian" <kurian.amal@t-online.de> wrote in message
> news:8v6ct8$jvj$07$1@news.t-online.com...
> > Robert Dewar wrote:
> >
> > > In article <3A2B4CF6@MailAndNews.com>,
> > >   Jean Cohen <jean.cohen@MailAndNews.com> wrote:
> > > 2.54
> > >
> > > I see an integer there, namely a 2, followed by junk, that's
> > > what Ada sees too!
> > >
> > >
> > > Sent via Deja.com http://www.deja.com/
> > > Before you buy.
> >
> > However while remaining quiet if the second number contains "junk"  Ada
> > screams loud if the same "junk" is contained in the first number. And I
> > think that's what the original poster was wondering about.
> >
> 
> I believe Robert answered the question.  If the first number entered is
> 2.54, an exception will occur when trying to read the second number.
> 
> SteveD
> 
> 
> 




  reply	other threads:[~2000-11-18  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-18  0:00 input/output exceptions Jean Cohen
2000-11-18  0:00 ` Robert Dewar
2000-11-18  0:00   ` Amal Kurian
2000-11-18  0:00     ` DuckE
2000-11-18  0:00       ` Amal Kurian [this message]
2000-11-19  0:00         ` Robert Dewar
     [not found]           ` <3A28353B.40B4F990@ebox.tninet.se>
     [not found]             ` <90dp4s$45c$1@nnrp1.deja.com>
2000-12-16 20:00               ` Stefan Skoglund
replies disabled

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