comp.lang.ada
 help / color / mirror / Atom feed
From: Brian Drummond <brian@shapes.demon.co.uk>
Subject: Re: Trouble with loop in Ada
Date: Fri, 4 Jan 2013 11:11:20 +0000 (UTC)
Date: 2013-01-04T11:11:20+00:00	[thread overview]
Message-ID: <kc6dco$37a$2@dont-email.me> (raw)
In-Reply-To: kc6cmc$37a$1@dont-email.me

On Fri, 04 Jan 2013 10:59:24 +0000, Brian Drummond wrote:

> On Fri, 04 Jan 2013 04:32:28 +0000, Derek Wyss wrote:
> 
>> Hello,
>> 
>> I'm new to Ada and I'm trying to write a toy unix command shell just to
>> explore the programming language.  
> 
> Now the good news : loops are more flexible in Ada; there are other ways
> of using them. So your immediate problem can be solved by:

Better...

  loop 
    Put("Enter a character> ");
    exit when End_Of_File;
    Get(input_char);
    Put("you entered: " & input_char);
    New_line;
  end loop;

With the exit at the bottom of the loop, its End_Of_File test required a 
second line of input (even just a <CR>). This version performs the test 
on the same line seen by the Get. 

- Brian



  reply	other threads:[~2013-01-04 11:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-04  4:32 Trouble with loop in Ada Derek Wyss
2013-01-04 10:59 ` Brian Drummond
2013-01-04 11:11   ` Brian Drummond [this message]
2013-01-04 12:44 ` Paul Colin Gloster
2013-01-04 21:27   ` Derek Wyss
2013-01-05  5:33     ` Randy Brukardt
replies disabled

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