From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,992e84f408e149d8 X-Google-Attributes: gid103376,public From: franke@minet.uni-jena.de (Frank Ecke) Subject: Re: How to initiate part of a string? Date: 1998/08/26 Message-ID: #1/1 X-Deja-AN: 384941010 References: <35E171AB.75CD@ddre.dk> <35E41EF7.7FC9309F@elca-matrix.ch> Organization: Friedrich-Schiller-University Jena, Germany Reply-To: franke@minet.uni-jena.de Newsgroups: comp.lang.ada Date: 1998-08-26T00:00:00+00:00 List-Id: On Wed, 26 Aug 1998 16:43:09, Mats Weber 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