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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1b6f0735bc6de58e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!l5g2000vbx.googlegroups.com!not-for-mail From: tonyg Newsgroups: comp.lang.ada Subject: Re: index check failure - constraint error Date: Fri, 1 Apr 2011 04:07:49 -0700 (PDT) Organization: http://groups.google.com Message-ID: <738ba46b-dfd1-4a28-9392-0be197a1b6d0@l5g2000vbx.googlegroups.com> References: NNTP-Posting-Host: 82.46.232.121 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301656069 8011 127.0.0.1 (1 Apr 2011 11:07:49 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 1 Apr 2011 11:07:49 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l5g2000vbx.googlegroups.com; posting-host=82.46.232.121; posting-account=28F2IwkAAACL1Z5nRC-dE7zuvWdbWC7P User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-GB; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.04 (lucid) Firefox/3.6.16,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19630 Date: 2011-04-01T04:07:49-07:00 List-Id: On Apr 1, 11:53=A0am, tonyg wrote: > I'm getting a constraint error and I cannot see why... > > =A0 =A0function String_To_Integer (The_String : String) return Integer is > =A0 =A0 =A0 String_Length : Integer :=3D The_String'length; > =A0 =A0 =A0 Return_Value : Integer :=3D 0; > =A0 =A0 =A0 subtype Number_Character =A0is character range '0'..'9'; > =A0 =A0begin > =A0 =A0 =A0 =A0 Int_Io.Put(String_Length); > =A0 =A0 =A0 Ada.Text_IO.Put_Line (The_String); > =A0 =A0 =A0 if String_Length > 0 then > =A0 =A0 =A0 for count in 1..String_Length loop > =A0 =A0 =A0 =A0 =A0case The_String(count) is > =A0 =A0 =A0 =A0 =A0 =A0 when Number_Character =3D> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Return_Value :=3D Return_Value + > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0((Character'pos(The_String(count)) - 4= 8) * > (10**(count-1))); > =A0 =A0 =A0 =A0 =A0 =A0 when others =3D> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0raise Conversion_Error_Exception; > =A0 =A0 =A0 =A0 =A0end case; > =A0 =A0 =A0 =A0 =A0end loop; > =A0 =A0 =A0 else > =A0 =A0 =A0 =A0 =A0Return_Value :=3D 0; > =A0 =A0 =A0 end if; > > =A0 =A0 =A0 return Return_Value; > > =A0 =A0end 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 ? The index check failure occurred at case The_String(count) is btw