From: stefan-lucks@see-the.signature
Subject: Re: type String_Type array(Integer range <>) of Character;
Date: Fri, 16 Apr 2010 23:09:28 +0200
Date: 2010-04-16T23:09:28+02:00 [thread overview]
Message-ID: <Pine.LNX.4.64.1004162257490.8234@medsec1.medien.uni-weimar.de> (raw)
In-Reply-To: <Xns9D5CA189A3710WarrensBlatherings@188.40.43.245>
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! ------
next prev parent reply other threads:[~2010-04-16 21:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-16 19:52 type String_Type array(Integer range <>) of Character; Warren
2010-04-16 21:09 ` stefan-lucks [this message]
2010-04-16 20:29 ` J-P. Rosen
2010-04-16 20:53 ` Charmed Snark
2010-04-16 20:56 ` Adam Beneschan
2010-04-19 15:27 ` Warren
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox