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.70.49.111 with SMTP id t15mr21075965pdn.10.1437207270692; Sat, 18 Jul 2015 01:14:30 -0700 (PDT) X-Received: by 10.50.1.66 with SMTP id 2mr24156igk.1.1437207270648; Sat, 18 Jul 2015 01:14:30 -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!qs7no7162640igc.0!news-out.google.com!t2ni14132igk.0!nntp.google.com!qs7no7162639igc.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 18 Jul 2015 01:14:29 -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 08:14:30 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:26865 Date: 2015-07-18T01:14:29-07:00 List-Id: On Friday, July 17, 2015 at 11:58:18 PM UTC+8, G.B. wrote: > On 17.07.15 17:47, Trish Cayetano wrote: > > Hi, > > > > I am getting error "exception not permitted here" when running below in= a loop. > > Well it runs if I put it outside the loop but I need it inside the loop= ... > > > > exception > > when ADA.IO_EXCEPTIONS.DATA_ERROR =3D> > > Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy"); > > > > Thanks in advance for your help... > > >=20 > does it look like >=20 > loop > ... > exception ... > ... > end loop >=20 > If so, then note that "exception" must be in a block, > such as a procedure body, or a block statement (LRM 5.6): >=20 >=20 > loop > begin > ... -- handled sequence of statements > exception ... > ... > end; > end loop >=20 > More complete examples would help reducing guess work. Thanks, David and GB. It still does not work...=20 Here is my own code (i removed the functions and others)... Sorry I am real= ly new to Ada. I actually tried also to put another loop and added declare,= begin and end. It hang after I ran. And when I terminated the process, it = looks like it ran infinitely in loops.=20 =20 =3D=3D=3D=3D=3D=20 --start of 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; =20 option : Integer :=3D 0; =20 endGame: Boolean :=3D False; begin while not endGame loop 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; exception when ADA.IO_EXCEPTIONS.Data_Error =3D> Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy"); end; end loop; end loop; end Main; --end of code =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RESULT: C:\Users\a0284014\Desktop\ada\exception\obj\main | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 1 Shuffle | CHOOSE YOUR OPTION: 1)Shuffle 2)Pass 3)Enter Word 4)Exit=20 e 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 --retracted repeats [2015-07-18 16:11:13] process exited with status 1, elapsed time: 19.58s