comp.lang.ada
 help / color / mirror / Atom feed
From: christoph grein <christoph.grein@eurocopter.de>
Subject: Re: Help: Get/Get_line
Date: 1998/05/20
Date: 1998-05-20T00:00:00+00:00	[thread overview]
Message-ID: <356231EB.3F2@eurocopter.de> (raw)
In-Reply-To: 355E0DE6.6867@info.polymtl.ca


This problem has a very simple solution, but the cause is not very
obvious. I've already sent the solution to someone before with the
request
to forward it to cla, but he didn't do this. So please forward the
solution.

You have to read the RM about Text_IO very carefully.

  get(number);

reads as many characters as can be interpreted as a whole number and
converts
this to the result type. Any other characters stay in the input stream.

So e.g. if you input "123.45", you will get "number=123", the next
"get_line(name, last);" will return ".45..." and any characters until
EOL or
name'last is reached, whatever occurs first.

So if you write

  get(number);
  get_line(name, last);

and enter on you keyboard

1234<return>

"get(number);" reads 1234, but leaves EOL, which is then immediately
read by
"get_line(name, last);", which will return "name" empty (unchanged) and
"Last=0".

This is quite confusing sometimes even to experienced programmers.

I hope this helps to let you sort out the solution of your problem.


Christoph




  parent reply	other threads:[~1998-05-20  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-16  0:00 Help: Get/Get_line John Slavich
1998-05-16  0:00 ` Matthew Heaney
1998-05-16  0:00 ` Tom Moran
1998-05-17  0:00   ` John Slavich
1998-05-17  0:00     ` Matthew Heaney
1998-05-17  0:00       ` John Slavich
1998-05-18  0:00         ` Dale Stanbrough
1998-05-20  0:00 ` christoph grein [this message]
1998-05-21  0:00   ` John J Cupak Jr, CCP
1998-05-22  0:00     ` Dale Stanbrough
1998-05-22  0:00     ` Assistance: Get/Get_line Anonymous
replies disabled

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