comp.lang.ada
 help / color / mirror / Atom feed
* index check failure - constraint error
@ 2011-04-01 10:53 tonyg
  2011-04-01 11:07 ` tonyg
                   ` (2 more replies)
  0 siblings, 3 replies; 18+ messages in thread
From: tonyg @ 2011-04-01 10:53 UTC (permalink / raw)



I'm getting a constraint error and I cannot see why...

   function String_To_Integer (The_String : String) return Integer is
      String_Length : Integer := The_String'length;
      Return_Value : Integer := 0;
      subtype Number_Character  is character range '0'..'9';
   begin
	Int_Io.Put(String_Length);
      Ada.Text_IO.Put_Line (The_String);
      if String_Length > 0 then
      for count in 1..String_Length loop
         case The_String(count) is
            when Number_Character =>
               Return_Value := Return_Value +
                 ((Character'pos(The_String(count)) - 48) *
(10**(count-1)));
            when others =>
               raise Conversion_Error_Exception;
         end case;
         end loop;
      else
         Return_Value := 0;
      end if;

      return Return_Value;

   end String_To_Integer;

I checked to see there was a string going in and it had a length. The
actual error was 'index check failure' but as far as I can see
everything is present and correct. Can anyone see what it is ?



^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2011-04-01 23:37 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-01 10:53 index check failure - constraint error tonyg
2011-04-01 11:07 ` tonyg
2011-04-01 11:27   ` Alex Mentis
2011-04-01 11:33     ` Alex Mentis
2011-04-01 11:36     ` Alex Mentis
2011-04-01 12:18     ` Georg Bauhaus
2011-04-01 22:20       ` tonyg
2011-04-01 23:37         ` Ludovic Brenta
2011-04-01 11:12 ` Egil Høvik
2011-04-01 11:17   ` tonyg
2011-04-01 12:13     ` Ludovic Brenta
2011-04-01 15:02     ` Adam Beneschan
2011-04-01 17:39 ` Jeffrey Carter
2011-04-01 22:16   ` tonyg
2011-04-01 22:31     ` Jeffrey Carter
2011-04-01 22:49       ` Robert A Duff
2011-04-01 23:00         ` Adam Beneschan
2011-04-01 23:29           ` Robert A Duff

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