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.182.46.227 with SMTP id y3mr14650099obm.7.1437223312787; Sat, 18 Jul 2015 05:41:52 -0700 (PDT) X-Received: by 10.50.107.105 with SMTP id hb9mr42392igb.3.1437223312756; Sat, 18 Jul 2015 05:41:52 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!qs7no7267703igc.0!news-out.google.com!a16ni21457ign.0!nntp.google.com!pg9no1851985igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Jul 2015 05:41:52 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=112.203.251.230; posting-account=7jTbjwoAAADuqLe9GO_M9l_Emer5tqxR NNTP-Posting-Host: 112.203.251.230 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Error "exception not permitted here" when putting EXCEPTION in a loop From: Trish Cayetano Injection-Date: Sat, 18 Jul 2015 12:41:52 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:26873 Date: 2015-07-18T05:41:52-07:00 List-Id: On Saturday, July 18, 2015 at 6:07:12 PM UTC+8, bj=F6rn lundin wrote: > On 2015-07-18 10:14, Trish Cayetano wrote: >=20 > e is my own code (i removed the functions and others)... S >=20 > orry I am really new to Ada. I actually tried also to put >=20 > another loop and added declare, begin and end. It >=20 > hang after I ran. And when I terminated the process, it looks like it > ran infinitely in loops. > >=20 >=20 > when you set endGame to true, > you are in the *inner* loop. > but the *outer* loop tests for endGame. >=20 > How do you exit the *inner* loop? >=20 > what purpose has the *inner* loop? >=20 > When you have the answer, > your program will be easy to fix. >=20 > -- > Bj=F6rn Hello Bj=F6rn,=20 I don't need the inner loop after all. I removed the inner loop but it still run in infinite loops. REVISED CODE: with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Numerics.Discrete_Random; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO; with Ada.IO_Exceptions; use Ada.IO_Exceptions; procedure Main is GuessWord : String(1..20); last: Natural; option : Integer :=3D 0; endGame: Boolean :=3D False; begin while not endGame loop begin Ada.Text_IO.Put_Line(" | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter= Word 4)Exit "); Ada.Integer_Text_IO.Get(option); case option is when 1 =3D> Ada.Text_IO.Put_Line("Shuffle"); when 2 =3D> Ada.Text_IO.Put_Line("Pass"); when 3 =3D> Skip_Line; Ada.Text_IO.Put_Line("Enter word: "); Ada.Text_IO.Get_Line(GuessWord, Last); when 4 =3D> Ada.Text_IO.Put_Line("See you again soon!"); endGame :=3D true; when others =3D> Ada.Text_IO.Put_Line("Invalid Option"); end case; Skip_Line; exception when ADA.IO_EXCEPTIONS.Data_Error =3D> Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy"); =20 end; =20 end loop; end Main; RESULT: C:\Users\a0284014\Desktop\ada\exception\obj\main | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 f Try a number from 1 to 4, Buddy | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 Try a number from 1 to 4, Buddy | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 Try a number from 1 to 4, Buddy | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 Try a number from 1 to 4, Buddy | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 Try a number from 1 to 4, Buddy [2015-07-18 20:39:33] process exited with status 1, elapsed time: 10.81s