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: Mats Weber Subject: Re: How to initiate part of a string? Date: 1998/08/26 Message-ID: <35E41EF7.7FC9309F@elca-matrix.ch>#1/1 X-Deja-AN: 384929447 Content-Transfer-Encoding: 7bit References: <35E171AB.75CD@ddre.dk> Content-Type: text/plain; charset=us-ascii Organization: ELCA Matrix SA Mime-Version: 1.0 Reply-To: Mats.Weber@elca-matrix.ch Newsgroups: comp.lang.ada Date: 1998-08-26T00:00:00+00:00 List-Id: Hans Marqvardsen wrote: > > I have a package GLOBALS, > containing global types and variables, > (but no procedures or functions). > > package Globals is --among other things > Txt: string (1..100); > end Globals; > > Is there a clean way to specify an initial value for a slice of Txt ? 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; This way, you need no package body, and you can easily change the value if Txt later on.