From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-2.9 required=3.0 tests=BAYES_00,NICE_REPLY_A autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!buffer2.nntp.dca1.giganews.com!buffer1.nntp.dca1.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sun, 09 Jan 2022 22:49:23 -0600 Subject: Re: Ok - WHAT are those "Maps.Identity" things ??? Newsgroups: comp.lang.ada References: From: "1.AAC0832" Date: Sun, 9 Jan 2022 23:49:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Message-ID: X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 98.77.165.67 X-Trace: sv3-lz6ojfav4mJFhCrWKKFX16Sf/DXWSHzYeT42pFP1bAT79mLZsFpxYZ4M6GlgT0Uz7UGjwMgBYxN6Qbo!jr3NxS+bZR3X0a6LpXu+aWzCWqs/LI/Jy5RCrFd4PbsxvpyyHqzYg2qC3ikgA+9D48YvY08BOV7R!hRvemhl1Dkg5BIuPhQA= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2617 Xref: reader02.eternal-september.org comp.lang.ada:63363 List-Id: On 1/7/22 6:48 AM, G.B. wrote: > On 07.01.22 03:31, 1.AAC0832 wrote: > >>    Gnat wants FOUR params ... and it's the last "map" related >>    one that's most mysterious. I'd also seen examples using >>    only TWO params ... but the compiler balks. >> >>    In any case : >>    Idx := Index >>          (Source  => S, >>           Pattern => P, >>           From    => Idx + 1); >> >>    won't compile no matter what you put in "from". > > In case you use the opaque type Unbounded_String everywhere, > and then the Index function, it is documented to want a String, > not an Unbounded_String for the Pattern. So, if that's the case, > get a normal (fixes size array) String from an Unbounded_String > object first. > > with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; > > function pos2 (hay_stack : Unbounded_String; needle : Unbounded_String) >   return Natural > is >    result : Natural; > begin >    result := Index (Source  => hay_stack, >                     Pattern => To_String(needle), >                     From    => 2); >    return result; > end pos2; I'll try it as writ. Someone else said the "needle" is a straight-up STRING however ... and I'd been sending an unbounded.