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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,6122265fe3a60a37 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-06-06 14:33:08 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!news1.rdc1.sfba.home.com.POSTED!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Some problems with string type(Exact String?) References: X-Newsreader: Tom's custom newsreader Message-ID: Date: Wed, 06 Jun 2001 21:30:04 GMT NNTP-Posting-Host: 24.7.82.199 X-Complaints-To: abuse@home.net X-Trace: news1.rdc1.sfba.home.com 991863004 24.7.82.199 (Wed, 06 Jun 2001 14:30:04 PDT) NNTP-Posting-Date: Wed, 06 Jun 2001 14:30:04 PDT Organization: Excite@Home - The Leader in Broadband http://home.com/faster Xref: archiver1.google.com comp.lang.ada:8268 Date: 2001-06-06T21:30:04+00:00 List-Id: >not greater than the bounds of the array. My first hunch on the way to >work with this strictness(or so it seems) would be keep count of the >number of elements (characters of a string, numbers, whatever) going into >the array, and then pad the rest of the array with with NULLs or something In Barnes, look at the chapter "Predefined Library", section "Characters and strings" and you'll see Ada.Strings.Bounded (and Ada.Strings.Unbounded). Bounded strings essentially keep a "current length", along with the fixed length array. There's no need then to pad with nulls or anything else. Alternatively, you could change > i.nameindex:=s; -- Ligne cinq to if s'length > i.nameindex'lenth then -- just take the first part i.nameindex := s(s'first .. s'first-1+i.nameindex'length) else -- pad with blanks i.nameindex := s & (s'length+1 .. i.nameindex'length => ' '); end if; or i.nameindex := s(s'first .. integer'min(s'length, i.nameindex'length) + s'first -1) & (1 .. i.namelength'length - s'length => ' '); which would truncate if s is too long, and pad with ' ' if s is too short. or, more simply, i.nameindex := Ada.Strings.Fixed.Head(s, i.namelength'length, pad => ' ');