comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: Ok - WHAT are those "Maps.Identity" things ???
Date: Fri, 7 Jan 2022 12:48:36 +0100	[thread overview]
Message-ID: <sr99al$avk$1@dont-email.me> (raw)
In-Reply-To: <AOmdnX_3T5ObO0r8nZ2dnUU7-IHNnZ2d@earthlink.com>

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;

  parent reply	other threads:[~2022-01-07 11:48 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-05  0:54 Ok - WHAT are those "Maps.Identity" things ??? 1.AAC0831
2022-01-05  5:49 ` Rod Kay
2022-01-07  2:31   ` 1.AAC0832
2022-01-07  3:39     ` Gautier write-only address
2022-01-07  4:14     ` Randy Brukardt
2022-01-10  5:13       ` 1.AAC0832
2022-01-10 10:19         ` Marius Amado-Alves
2022-01-11  5:20           ` 1.AAC0832
2022-01-07 11:48     ` G.B. [this message]
2022-01-10  4:49       ` 1.AAC0832
2022-01-05 13:01 ` Jeffrey R.Carter
2022-01-07  2:41   ` 1.AAC0832
2022-01-07  9:49     ` Jeffrey R.Carter
2022-01-10  4:46       ` 1.AAC0832
2022-01-10 15:05         ` Simon Wright
2022-01-11  5:17           ` 1.AAC0832
2022-01-11 11:33             ` Niklas Holsti
2022-01-12  4:22               ` 1.AAC0832
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox