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=-1.3 required=3.0 tests=BAYES_00,NICE_REPLY_A, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.6 Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "G.B." Newsgroups: comp.lang.ada Subject: Re: Ok - WHAT are those "Maps.Identity" things ??? Date: Fri, 7 Jan 2022 12:48:36 +0100 Organization: A noiseless patient Spider Message-ID: References: Reply-To: nonlegitur@notmyhomepage.de Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 7 Jan 2022 11:48:37 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="8f530c1108a8e7ceadbf1b1e17c5b30d"; logging-data="11252"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QwQvkxvegIhRkExGjNMSeseO6/BkZAYY=" User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.4.1 Cancel-Lock: sha1:lL6SE+3krs4PrCJIN0o4PkzffG4= In-Reply-To: Content-Language: en-US Xref: reader02.eternal-september.org comp.lang.ada:63354 List-Id: 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;