From: franke@minet.uni-jena.de (Frank Ecke)
Subject: Re: How to initiate part of a string?
Date: 1998/08/26
Date: 1998-08-26T00:00:00+00:00 [thread overview]
Message-ID: <slrn6u8a87.7n2.franke@pax10f.mipool.uni-jena.de> (raw)
In-Reply-To: 35E41EF7.7FC9309F@elca-matrix.ch
On Wed, 26 Aug 1998 16:43:09, Mats Weber <Mats.Weber@elca-matrix.ch> wrote:
>If the value, and especially the length, of that string is going to change,
>then String(1 .. 100) is a very bad type to use. Instead, you should use one
>of the varying length string packages Ada.Strings.Bounded and Ada.Strings.
>Unbounded.
>
>Example:
>
>with Ada.Strings.Unbounded;
>
>use Ada.Strings.Unbounded;
>
>package Globals is
> Txt : Unbounded_String := To_Unbounded_String("bla bla bla");
>end Globals;
>
B
>This way, you need no package body, and you can easily change the value if Txt
>later on.
Of course, unbounded strings provide more flexibility but I think Hans'
intention was to provide an initial value for a *slice* of Txt. Your proposal
seems to only initialize a ``special slice'' of Txt, namely
Txt(1 .. Length("bla bla bla")).
Using unbounded strings, I suggest:
Txt : Unbounded_String :=
Replace_Slice(100 * Space, 50, 54, "Hello");
or, as suggested by Hans:
Txt : Unbounded_String :=
Overwrite(100 * Space, 5, "No need to count");
Regards,
Frank
prev parent reply other threads:[~1998-08-26 0:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-24 0:00 How to initiate part of a string? Hans Marqvardsen
1998-08-25 0:00 ` Mark A Biggar
1998-08-25 0:00 ` Tom Moran
1998-08-25 0:00 ` Samuel Tardieu
1998-08-26 0:00 ` Tom Moran
1998-08-26 0:00 ` Robert I. Eachus
1998-08-26 0:00 ` Tom Moran
1998-09-24 0:00 ` Bob Fletcher
1998-09-24 0:00 ` Tom Moran
1998-09-25 0:00 ` dewarr
1998-09-29 0:00 ` Aidan Skinner
1998-09-19 0:00 ` dewarr
1998-08-26 0:00 ` Frank Ecke
1998-08-26 0:00 ` Robert I. Eachus
1998-08-26 0:00 ` Mats Weber
1998-08-26 0:00 ` Frank Ecke [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox