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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Substrings as argument to procedures/functions Date: Wed, 13 Apr 2016 09:57:27 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <2055a188-fb5f-496a-ab37-b25d81cebe1b@googlegroups.com> <5271bc70-bfea-4e2f-b4e3-6c847843f5b4@googlegroups.com> <9c28eac4-8edf-45dc-afcd-082abfd4cf4b@googlegroups.com> <1460548465.940.5.camel@obry.net> <861t69r8r9.fsf@gaheris.avalon.lan> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Wed, 13 Apr 2016 16:54:09 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="48b46be33beed75863f69afa437f956b"; logging-data="13348"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/N0ugNdRaaiEMwg60iqyz6oqZSm6dTEh4=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 In-Reply-To: <861t69r8r9.fsf@gaheris.avalon.lan> Cancel-Lock: sha1:oPtET/5IMH3iJ1KiJC23vfyj9s0= Xref: news.eternal-september.org comp.lang.ada:30100 Date: 2016-04-13T09:57:27-07:00 List-Id: On 04/13/2016 05:30 AM, Mart van de Wege wrote: > > I do have a minor question here though: That does not work if you have > any reason to try and modify the first character of a String. S(1) := > To_Upper(S(1)) works, but S'First := To_Upper(S'First) does not. S is an array. 1 is an index into that array. S (1) is the component of S at index 1, which is a Character. So your 1st statement passes a Character to a function and assigns the result to a Character. S'First is an index into S. It is also constant. So your 2nd statement attempts to pass an Integer to a function that expects a Character, and tries to assign the result to a constant. If you use the index S'First in the same way as you used the index 1, things will probably work better for you. -- Jeff Carter "Violence is the last refuge of the incompetent." Foundation 151