comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <mheaney@on2.com>
Subject: Re: String declaration and initialization
Date: Thu, 22 May 2008 11:16:22 -0700 (PDT)
Date: 2008-05-22T11:16:22-07:00	[thread overview]
Message-ID: <37455a58-73f4-4c68-afbd-7dc405de78d8@m3g2000hsc.googlegroups.com> (raw)
In-Reply-To: g148oh$mcd$1@registered.motzarella.org

On May 22, 12:58 pm, Sébastien <seb.mor...@gmail.com> wrote:
>
> > declare
> >   Test1 : aliased constant String := "test1";
> >   Test2 : aliased constant String := "test2";
>
> >   type Table_Type is array (Test_Type) of
> >     not null access constant String;
>
> >   Table : constant Table_Type :=
> >     (T1 => Test1'Access,
> >      T2 => Test2'Access,
> >      ...);
>
> >   S : String renames Table (Some_Test).all;
> > begin
> > ...
> > end;
>
> That's an idea but... Test1 are actually not a constant string, that was
> an example :-) It's calculated sometime it's even a return of some
> function and so on.

That doesn't really change anything.  You could say:

declare
  Test1 : aliased constant String := Result_Of_Function1;
  Test2 : aliased constant String := Result_Of_Function2;
...
begin



>      MyTreatment1(buffer.all, buffer.all'Size);

What are you trying to do here?  Why can't you simply declare
MyTreatment1 like this:

  procedure MyTreatment1 (S : String) is ...;

and then call it like this:

  MyTreatment1 (buffer.all);


> end;
>
> but it doesn't work of course since I can't create with new an
> unconstrained object.

No, Bob showed you what to do:

  ... new String'("this is my string");





  parent reply	other threads:[~2008-05-22 18:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-22 15:47 String declaration and initialization Sébastien
2008-05-22 16:05 ` Dmitry A. Kazakov
2008-05-22 16:47   ` Sébastien
2008-05-23  8:18     ` Dmitry A. Kazakov
2008-05-23  9:33       ` Sébastien
2008-05-22 16:16 ` Matthew Heaney
2008-05-22 16:58   ` Sébastien
2008-05-22 17:11     ` Robert A Duff
2008-05-22 18:16     ` Matthew Heaney [this message]
2008-05-22 20:01     ` Jeffrey R. Carter
2008-05-22 16:40 ` Jean-Pierre Rosen
2008-05-22 18:09 ` Martin Krischik
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox