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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3a2f76c3562b7f58 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!nf02.dk.telia.net!starscream.dk.telia.net!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!news-1.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: type String_Type array(Integer range <>) of Character; Date: Fri, 16 Apr 2010 23:09:28 +0200 Organization: Bauhaus-Universitaet Weimar Message-ID: References: Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: tigger.scc.uni-weimar.de 1271448927 18852 141.54.178.228 (16 Apr 2010 20:15:27 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Fri, 16 Apr 2010 20:15:27 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Xref: g2news2.google.com comp.lang.ada:10995 Date: 2010-04-16T23:09:28+02:00 List-Id: On Fri, 16 Apr 2010, Warren wrote: > procedure M is > > type String_Type is array(Integer range <>) of Character; > > S : String_Type := "Abc."; > T : String(1..4); > begin > T := String(S); -- this raises Constraint_Error > Put_Line(T); > > end M; Convert S into a variable of type String_Type with String-compatible bounds, and then convert that variable into a String: S : String_Type := "Abc."; T : String_Type(1 .. S'Length) := S; U : String(1 .. S'Length); begin U := String(T); Put_Line(U); -- or just Put_Line(String(T)); If you have to do that frequently, use an appropriate function (without any need to copy the String-like thing character by character): function To_String(S: String_Type) return String is X: String_Type(1 .. S'Length) := S; begin return String(X); end To_String; I hope that helps! Stefan -- ------ Stefan Lucks -- Bauhaus-University Weimar -- Germany ------ Stefan dot Lucks at uni minus weimar dot de ------ I love the taste of Cryptanalysis in the morning! ------