comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: String declaration and initialization
Date: Thu, 22 May 2008 18:05:50 +0200
Date: 2008-05-22T18:05:50+02:00	[thread overview]
Message-ID: <1sx14jlsjttyu$.me8s3y39ipru.dlg@40tude.net> (raw)
In-Reply-To: g144j0$4cn$1@registered.motzarella.org

On Thu, 22 May 2008 15:47:38 +0000, S�bastien wrote:

> Several times I had to do the following:
> 
> declare
> 	buffer: String; --  Error at compile time
> begin
> 	case SomeTest is
> 		case TEST1 =>
> 			buffer := "Test1";
> 		case TEST2 =>
> 			buffer := "Test2";
> 	end case;
> 	MyTreatment1(buffer, buffer'Size);

You don't need buffer'Size, even if you incidentally meant buffer'Length...

> 	MyTreatment2(buffer, buffer'Size);
> 	MyTreatment3(buffer, buffer'Size);
> end;
> 
> But How can I do this since I can't declare a string without constraint?

declare
   function Test return String is -- Ada has scoped subprograms
   begin
      case Some_Test is
         when Test_1 => return "Test1";
         ...
      end case;
   end Test;
   Buffer: constant String := Test;
begin
   My_Treatment_1 (Buffer);
   ...

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-05-22 16:05 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 [this message]
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
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