From: labtek@cs.yale.edu (Tom Griest)
Subject: Re: Strange problem in GNAT 3.04 Win 95
Date: 1996/10/26
Date: 1996-10-26T00:00:00+00:00 [thread overview]
Message-ID: <54to1mINNqeb@RA.DEPT.CS.YALE.EDU> (raw)
In-Reply-To: 32707cd0.8077937@news.demon.co.uk
smoore@chowgar.demon.co.uk (Simon Moore) writes:
>If anybody has got the time could they please take a look at the
>listing below. The code seems syntactically and semantically correct
>but doesn't perform as it should.
You are missing statement to flush the rest of the input line
when you do a get on the integer. You need a Skip_Line; after
the Get(Choice);
[snip]
> PUT_LINE("1 - Get a natural");
> PUT_LINE("2 - Get a character");
> PUT_LINE("3 - Nothing");
> PUT_LINE("4 - Nothing");
> NEW_LINE;
> PUT_LINE("0 - Exit");
>
> GET(choice);
>
> -- ** GET(c); -- THIS IS THE IMPORTANT LINE
>
Get(C) will not work in the general case, and specifically if the
user enters additional (possibly space) characters after the number.
BTW, it is good practice to use bullet-proof input routines for
this sort of thing, since a user making a typo could easily get
an unhandled exception in your example.
The reason why case 1 works, but not case two is that the get on
integer is defined to scan over non-numeric characters, whereas
get on a character simply returns the next input character.
-Tom
next prev parent reply other threads:[~1996-10-26 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-24 0:00 Strange problem in GNAT 3.04 Win 95 Simon Moore
1996-10-24 0:00 ` Nicolay Belofastow
1996-10-25 0:00 ` Simon Moore
1996-10-25 0:00 ` Pascal Obry
1996-10-26 0:00 ` Tom Griest [this message]
1996-10-31 0:00 ` John English
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox