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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID 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: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: How to initiate part of a string? Date: 1998/08/26 Message-ID: #1/1 X-Deja-AN: 384946833 References: <35E171AB.75CD@ddre.dk> <35e2dc46.1973509@SantaClara01.news.InterNex.Net> <35e3675e.37587430@SantaClara01.news.InterNex.Net> Organization: The Mitre Corp., Bedford, MA. Newsgroups: comp.lang.ada Date: 1998-08-26T00:00:00+00:00 List-Id: In article <35e3675e.37587430@SantaClara01.news.InterNex.Net> tmoran@bix.com (Tom Moran) writes: Quite so, it should have been Txt : String(1 .. 100) := (1 .. 27=>' ') & "abcd" & (32 .. 100=>' '); That actually is not the same thing. The bounds of "abcd" are 1..4, but the catenation preserves the lower bound of the leftmost entry. So: Txt : String(1 .. 100) := (1 .. 27=>' ') & "abcd" & (1 .. 69=>' '); is equivalent, except for expository purposes. To create an aggregate that can initialize the string write: Txt2: String(1..100) := (1..27 => ' ', 28 => 'a', 29 => 'b', 30 => 'c', 31 => 'd', 32..100 => ' '); Painful, but at least in this case you get better bounds info. Better still try: Txt3: String(1..100) := (28 => 'a', 29 => 'b', 30 => 'c', 31 => 'd', others => ' '); Of course, reality is that if you really need to do something like this, you would, I hope, use the standard libraries: with Ada.Strings.Fixed;use Ada.Strings.Fixed; ... Txt4: String(1..100) := Overwrite(Source => String'(1..100 => ' '), Position => 28, New_Item => "abcd"); Now finally, I can answer the original question. Note that Source argument above was provided as an aggregate, I could also have written, using the "*" function in Ada.Strings.Fixed: Txt5: String(1..100) := Overwrite(Source => 100 * ' ', Position => 28, New_Item => "abcd"); or if you really insist on partial initialization: Junk: String(1..100); -- uninitialized Txt6: String(1..100) := Overwrite(Source => Junk, Position => 28, New_Item => "abcd"); -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...