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 autolearn=ham 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!34g2000pru.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: index check failure - constraint error Date: Fri, 1 Apr 2011 08:02:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: <01c141e6-9331-4ca4-823d-ee19ab58631e@34g2000pru.googlegroups.com> References: <64114572-3a55-4a5f-b1f8-70ee0a67fd2f@glegroupsg2000goo.googlegroups.com> <50a187ed-f454-47c5-af00-e40a0fc4eb2f@p3g2000vbv.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1301670139 19633 127.0.0.1 (1 Apr 2011 15:02:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 1 Apr 2011 15:02:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: 34g2000pru.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:19638 Date: 2011-04-01T08:02:19-07:00 List-Id: On Apr 1, 4:17=A0am, tonyg wrote: > On Apr 1, 12:12=A0pm, Egil H=F8vik wrote: > > > In your loop you assume The_String'First=3D1, > > that may not always be the case, especially if > > you call this function on array slices. > > Try "for count in The_String'Range loop" instead > > > -- > > ~egilhh > > Worked a treat - still don't understand why the first character in the > string is not 1 though, > Thanks for the help A String is an array (of Character), and like any array, it can have any bounds you give it. (Well, not quite: a non-empty String's bounds have to be 1 or greater. But you can declare a string like: S : String (10 .. 20); and if you pass S to this routine, S'First will be 10 and S'Last will be 20, and S'Length will be 11. Does that make more sense? Also, others have mentioned the ability to take a slice of an array, including a String.) -- Adam