From: stefan-lucks@see-the.signature
Subject: Re: Array slices and types
Date: Wed, 20 Aug 2008 19:47:35 +0200
Date: 2008-08-20T19:47:35+02:00 [thread overview]
Message-ID: <Pine.LNX.4.64.0808201942340.32536@medsec1.medien.uni-weimar.de> (raw)
In-Reply-To: <5886ab95-8744-4b72-b911-e4cb8889c7e7@d1g2000hsg.googlegroups.com>
On Wed, 20 Aug 2008, Maciej Sobczak wrote:
> Consider this:
>
> type Name is new String (1 .. 10);
>
> N : Name;
>
> Some_String : String := "abc";
>
> How can I assign Some_String to the beginning slice (ie. to the first
> three characters) of N?
Some_String does always contain exactly ten characters, no more, no less.
But you can assign the first three characters of Some_String to name:
N(1 .. 3) := Some_String;
> Everything that I can think of (short of copying characters
> individually) hits the type compatibility problem.
Here is a completely compilable example:
with Ada.Text_IO;
procedure Slice is
S: String(1 .. 3);
T: String(1 .. 5) := (others => '*');
U: String(1 .. 9) := (others => '-');
begin
S := T(1 .. 3);
U(1 .. 5) := T;
Ada.Text_IO.Put_Line(S & "|" & T & "|" & U);
end Slice;
As expected, the output is a line with the string "***|*****|*****----".
--
------ 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:[~2008-08-20 17:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-20 14:51 Array slices and types Maciej Sobczak
2008-08-20 15:26 ` Niklas Holsti
2008-08-20 15:46 ` Dmitry A. Kazakov
2008-08-20 18:52 ` Niklas Holsti
2008-08-20 20:01 ` Simon Wright
2008-08-21 5:26 ` Niklas Holsti
2008-08-21 8:53 ` Dmitry A. Kazakov
2008-08-21 14:44 ` Adam Beneschan
2008-08-21 15:46 ` Dmitry A. Kazakov
2008-08-22 4:30 ` Randy Brukardt
2008-08-20 17:47 ` stefan-lucks [this message]
2008-08-20 17:51 ` stefan-lucks
2008-08-20 20:45 ` Adam Beneschan
2008-08-21 21:16 ` Maciej Sobczak
2008-08-23 2:50 ` Steve
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox