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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,146ef816afa699d1 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.21.229 with SMTP id y5mr20779979pbe.1.1318759119403; Sun, 16 Oct 2011 02:58:39 -0700 (PDT) Path: d5ni15687pbc.0!nntp.google.com!news2.google.com!news4.google.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Length of unbounded_string. Date: Sun, 16 Oct 2011 11:59:38 +0200 Organization: Tidorum Ltd Message-ID: <9fvo6aF3d6U1@mid.individual.net> References: <4e9a9a6d$0$3238$703f8584@news.kpn.nl> Mime-Version: 1.0 X-Trace: individual.net bmU6apPSFhiUTO5ltgs9ugJ2LdAaiBx3jDC7TpTfGLaFPMRLIe Cancel-Lock: sha1:OnVanXotiy2KEsHc0PklO3oMpoQ= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2 In-Reply-To: <4e9a9a6d$0$3238$703f8584@news.kpn.nl> Xref: news2.google.com comp.lang.ada:13970 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Date: 2011-10-16T11:59:38+02:00 List-Id: On 11-10-16 10:48 , ldries46 wrote: > In my program I use unbounded_string str > > I want to change the last character of the string using the program lines > > 2205 len := Length(str); > 2206 Replace_Slice(str, len, len, "G"); Similar code works for me (debian, gnat). It seems to me that code like the above can fail with Constraint_Error only if str is the null string, in which case len = 0, which causes a Constraint_Error in the call because the 2nd parameter of Replace_Slice is of subtype Positive. > Then I get the following message printed in my exception part of the > program ... > Original line : /* GtkPrintJob ... > In this print out the Original line represents "str". Are you certain that your "str" is really that, and is not a null string? I would put a check in the code, before the call of Replace_Slice, and not trust the exception messages. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .