comp.lang.ada
 help / color / mirror / Atom feed
From: "1.AAC0832" <z24ba7.net>
Subject: Re: Ok - WHAT are those "Maps.Identity" things ???
Date: Sun, 9 Jan 2022 23:49:23 -0500	[thread overview]
Message-ID: <ULidnZVWIOBOJ0b8nZ2dnUU7-Q-dnZ2d@earthlink.com> (raw)
In-Reply-To: <sr99al$avk$1@dont-email.me>

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.


  reply	other threads:[~2022-01-10  4:49 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.
2022-01-10  4:49       ` 1.AAC0832 [this message]
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