comp.lang.ada
 help / color / mirror / Atom feed
From: Stewart <s_aitken@lineone.net>
Subject: Re: Data_Error - Where in this code?
Date: Wed, 08 Aug 2001 10:31:22 +0100
Date: 2001-08-08T10:31:22+01:00	[thread overview]
Message-ID: <lb12ntcg0di3ego99m8sbqrquffmah1uq9@4ax.com> (raw)
In-Reply-To: 1qstmt4hiaiutibe0jies4j0v04ll7mahs@4ax.com

On Mon, 06 Aug 2001 20:47:41 +0100, Stewart <s_aitken@lineone.net>
wrote:
Hi,

I still get the Max_Size is not declared, but it is not defined until
the variable for the input is obtained. If I put a value in Max_Size I
get the constraint_error for the value declared.

It now functions as required in both Win98/Dos and Linux.
Gnat 3.13.

I just have to glue it to the load procedure now.


Thanks

Stewart

>-- Menu commands  --
>-- 8 Aug  working properly   --
>
>   with Ada.Text_Io;
>   use Ada.Text_Io;
>   procedure Menu is
> 
>      type Edge_Cost is new Integer range 1 .. 999;
>      package Cost_InOut is new Integer_Io(Edge_Cost);
>      package Number_InOut is new Integer_Io(Integer);
>      use Cost_InOut, Number_InOut;
>  
>      Max_Size  : Positive;  
>      Int_Range : Natural; 
>      Edge      : Edge_Cost; 
>      Input     : String (1 .. Max_Size);  
>      Add       : String (1 .. 3)        := "add";  
>      Remove    : String (1 .. 6)        := "remove";  
>      Link      : String (1 .. 4)        := "link";  
>      Cost      : String (1 .. 4)        := "cost";  
>      Quit      : String (1 .. 4)        := "quit";  
>      Nodea     : String (1 .. 6); Nodeb     : String (1 .. 6);  
>       
>   
>   begin
>      loop
>         begin -- Block to contain the exception.   --
>            New_Line; Put("Please enter command: ");
>            Get_Line(Input, Max_Size); New_Line;
>            if Input(1..3) = Add and  10 = Max_Size then
>               Nodea := Input(5..10); New_Line;
>            elsif Input(1..6) = Remove and  13 = Max_Size then
>               Nodea := Input(8..13); New_Line;
>            elsif Input(1..4) = Link and 19 < Max_Size and Max_Size < 23 then
>               Nodea := Input(6..11); 
>               Nodeb := Input(13..18); 
>               Int_Range := Max_Size - 19; New_Line;
>            
>               case Int_Range is
>                  when 1 =>
>                     Edge  := Edge_Cost'Value(Input(19..20));
>               --                   Convert a single numeral   --           
>                  when 2 =>
>                     Edge  := Edge_Cost'Value(Input(20..21));
>               --                   Convert two numerals        --                 
>                  when 3 =>
>                     Edge  := Edge_Cost'Value(Input(20..22));
>               --                   Convert three numerals       --              
>                  when others => null; -- To capture case 0 and 4 --
>               end case;                 
>            elsif Input(1..4) = Cost and  11 = Max_Size then
>               Nodea := Input(6..11); 
>            elsif Input(1..4) = Quit then
>               exit when Input(1..4) = Quit;
>            else
>               Put ("Sorry, do not understand command."); New_Line;
>               Put ("Try again."); New_Line;
>            end if;
>            exception
>               when CONSTRAINT_ERROR =>
>                  Put("Error in Cost Value. Enter 1 to 999 only.");
>                  new_line;
>         end;      --  End Block to contain exception            --
>      end loop;
>   end Menu;




  parent reply	other threads:[~2001-08-08  9:31 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-06 19:47 Data_Error - Where in this code? Stewart
2001-08-07 13:53 ` Mark Johnson
2001-08-08  9:31 ` Stewart [this message]
2001-08-08 13:08   ` Mark Johnson
2001-08-09  9:34     ` Stewart
2001-08-09 13:27       ` Mark Johnson
2001-08-09 17:55         ` Stewart
replies disabled

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