From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.197.136 with SMTP id ek8mr1517807icb.32.1389212875422; Wed, 08 Jan 2014 12:27:55 -0800 (PST) X-Received: by 10.182.28.100 with SMTP id a4mr41216obh.28.1389212874646; Wed, 08 Jan 2014 12:27:54 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!z4no3250292qaw.1!news-out.google.com!l9ni8458qay.0!nntp.google.com!p15no3245032qaj.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 8 Jan 2014 12:27:54 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=149.32.224.34; posting-account=Qh2kiQoAAADpCLlhT_KTYoGO8dU3n4I6 NNTP-Posting-Host: 149.32.224.34 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <66e43abe-7918-4296-a12f-a8454ea4cd80@googlegroups.com> Subject: Did I understand it or not From: Anh Vo Injection-Date: Wed, 08 Jan 2014 20:27:54 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 2553 X-Received-Body-CRC: 1844597133 Xref: news.eternal-september.org comp.lang.ada:18136 Date: 2014-01-08T12:27:54-08:00 List-Id: with Ada.Text_Io; use Ada; procedure The_Unexpected is package Char_Io is new Ada.Text_Io.Enumeration_Io (Character); Health_Choice : Character :=3D 'T'; use Text_Io; begin Health_Selection: loop begin Put ("Select Health Status '0', '1' or '2' =3D> "); Char_Io.Get (Health_Choice); Put_Line (" < character '" & Health_Choice & "' is selected"); if Health_Choice =3D '0' or else Health_Choice =3D '1' or else Health_Choice =3D '2' then exit; else Put ("Illegal selection! Choose another character > "); end if; exception when Data_Error =3D> Put_Line ("Use single quote like '0' or '1'"); Flush; end; end loop Health_Selection; end The_Unexpected; --------------------------------------- GNAT was used on Linux and PC I thought this piece of code should behave correctly regardless good or bad= input from the operator. If a bad data is input, it is rejected and ask fo= r another data input. However, it went to an infinite loop when a bad input= is entered. For example, the program is in infinite loop if the operator t= ype 1 instead of '1' when prompted. I strongly believe that Flush subprogram did not clear the previous input f= rom the terminal. Thus, Char_Io.Get completes without waiting for the input= from the operator. Once it is confirmed, I will compile a bug report. Thank you in advance for= your help. Anh Vo