comp.lang.ada
 help / color / mirror / Atom feed
From: john@assen.demon.co.uk (John McCabe)
Subject: Re: Simple ADA/C Question
Date: 1997/02/26
Date: 1997-02-26T00:00:00+00:00	[thread overview]
Message-ID: <33149c72.1548994@news.demon.co.uk> (raw)
In-Reply-To: Pine.LNX.3.95.970226082729.7991A-100000@vf700f.msfc.nasa.gov


root <root@vf700f.msfc.nasa.gov> wrote:

>On 26 Feb 1997, Bob Klungle wrote:
>
>begin
>  while To_Lower( Answer ) = 'y'
>  loop
>    Integer_To_Ada := Do_C2;
>    New_Line;
>    Put_Line( "the integer returned from the ADA function that called ");
>    Put_Line( "the C function is " );
>    Put( Integer_To_Ada );
>    New_Line( 2 );
>    Put( "do you want to run again ( y/n )? " );
>    Get( Answer );
>  end loop;

<..snip..>

>I'm not capturing any exception and I don't get any exception that crashes
>the program.  Well, I guess since the program exits as if the default
>condition was met, this is not an exception crash?  As you can tell, it is
>not obvious to me that an exception has occurred :).  I'll go back and
>read about exceptions and handling and try to figure this out.

Since you didn't include all the code, I can't be sure whether this is
the answer or not and have to make some assumptions however..

It sounds to me like you're trying to read an integer input and
actually putting in a real e.g. 2.0. The input routine is finding the
"." of 2.0 and doesn't like it (you don't get "." in integers!)
therefore it abandons any further read leaving the input buffer with
the ".0" in it.

The next read (Get( Answer ); above) then reads in the character "."
and since it isn't a "y" the program terminates.

Therefore at some point you have to handle the input better, flushing
the input buffer if you detect a failure of some sort. In the C
function you have imported do you check for return values from the
input routines (e.g. scanf)? If not then you are probably seeing what
I've described here.

Good luck.

Best Regards
John McCabe <john@assen.demon.co.uk>




  parent reply	other threads:[~1997-02-26  0:00 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-25  0:00 Simple ADA/C Question root
1997-02-26  0:00 ` Bob Klungle
1997-02-26  0:00   ` root
1997-02-26  0:00     ` Stephen Leake
1997-02-26  0:00       ` root
1997-02-26  0:00     ` John McCabe [this message]
1997-02-26  0:00     ` Robert Dewar
1997-02-28  0:00       ` Keith Thompson
1997-03-02  0:00         ` Robert Dewar
1997-03-04  0:00           ` Keith Thompson
1997-03-04  0:00             ` Robert Dewar
1997-03-04  0:00               ` John McCabe
1997-03-04  0:00                 ` Anders Eliasson
1997-03-04  0:00                 ` Robert Dewar
1997-03-06  0:00                   ` Keith Thompson
1997-03-06  0:00                     ` Larry Kilgallen
1997-03-09  0:00                       ` Robert Dewar
1997-03-06  0:00                     ` Robert Dewar
1997-02-27  0:00 ` Robert Dewar
1997-02-27  0:00   ` root
1997-02-27  0:00   ` root
1997-03-03  0:00 ` Robert I. Eachus
1997-03-05  0:00   ` Robert Dewar
1997-03-05  0:00 ` Jon S Anthony
1997-03-06  0:00   ` Robert Dewar
1997-03-07  0:00 ` Jon S Anthony
1997-03-07  0:00   ` Robert Dewar
1997-03-07  0:00   ` Robert Dewar
1997-03-08  0:00     ` Larry Kilgallen
replies disabled

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