comp.lang.ada
 help / color / mirror / Atom feed
From: "Björn Lundin" <b.f.lundin@gmail.com>
Subject: Re: Error "exception not permitted here" when putting EXCEPTION in a loop
Date: Sat, 18 Jul 2015 16:59:30 +0200
Date: 2015-07-18T16:59:30+02:00	[thread overview]
Message-ID: <modpfg$8cd$1@dont-email.me> (raw)
In-Reply-To: <f6eefaa7-eebb-4489-bda6-81bbccbfc50f@googlegroups.com>

On 2015-07-18 16:32, Trish Cayetano wrote:
> On Saturday, July 18, 2015 at 9:55:12 PM UTC+8, björn lundin wrote:

This one works.
As Tero said - skip_line in exception handler does it.
But you ONLY need it there.

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 := 0;
   endGame: Boolean := 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 =>
                Ada.Text_IO.Put_Line("Shuffle");
             when 2 =>
                Ada.Text_IO.Put_Line("Pass");
             when 3 =>
                Skip_Line; -- needed ????
                Ada.Text_IO.Put_Line("Enter word: ");
                Ada.Text_IO.Get_Line(GuessWord, Last);
             when 4 =>
                Ada.Text_IO.Put_Line("See you again soon!");
                endGame := true;
             when others =>
                Ada.Text_IO.Put_Line("Invalid Option");
          end case;
	exception
	  when ADA.IO_EXCEPTIONS.Data_Error =>
	    Ada.Text_IO.Put_Line ("Try a number from 1 to 4, Buddy");
	    skip_line;
         end;
     end loop;
end Main;

--
Björn

  reply	other threads:[~2015-07-18 14:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17 15:47 Error "exception not permitted here" when putting EXCEPTION in a loop Trish Cayetano
2015-07-17 15:56 ` David Botton
2015-07-17 15:58 ` G.B.
2015-07-18  8:14   ` Trish Cayetano
2015-07-18 10:08     ` Björn Lundin
2015-07-18 12:41       ` Trish Cayetano
2015-07-18 13:56         ` Björn Lundin
2015-07-18 14:08           ` Niklas Holsti
2015-07-18 14:56             ` Björn Lundin
2015-07-18 14:32           ` Trish Cayetano
2015-07-18 14:59             ` Björn Lundin [this message]
2015-07-18 16:09             ` Dennis Lee Bieber
2015-07-18 18:11               ` Niklas Holsti
2015-07-18 21:16                 ` Dennis Lee Bieber
2015-07-17 16:02 ` Björn Lundin
replies disabled

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