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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2f343e3986ead102 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!postnews.google.com!l64g2000hse.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: String declaration and initialization Date: Thu, 22 May 2008 09:16:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: <05bce551-cd98-417c-8664-847b29124c19@l64g2000hse.googlegroups.com> References: NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1211472979 18541 127.0.0.1 (22 May 2008 16:16:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 22 May 2008 16:16:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: l64g2000hse.googlegroups.com; posting-host=66.162.65.129; posting-account=umyUbgkAAADe5rQC4VzV-ffCoH4N30u3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:289 Date: 2008-05-22T09:16:19-07:00 List-Id: On May 22, 11:47=A0am, S=E9bastien wrote: > > declare > =A0 =A0 =A0 =A0 buffer: String; -- =A0Error at compile time > begin > =A0 =A0 =A0 =A0 case SomeTest is > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 case TEST1 =3D> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 buffer :=3D "Test1"; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 case TEST2 =3D> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 buffer :=3D "Test2"; > =A0 =A0 =A0 =A0 end case; > =A0 =A0 =A0 =A0 MyTreatment1(buffer, buffer'Size); > =A0 =A0 =A0 =A0 MyTreatment2(buffer, buffer'Size); > =A0 =A0 =A0 =A0 MyTreatment3(buffer, buffer'Size); > end; > > But How can I do this since I can't declare a string without constraint? The simplest way is to use a bounded or unbounded string: declare S : Unbounded_String; begin case Some_Test is when T1 =3D> S :=3D To_Unbounded_String ("test1"); ... end; Another way is to use a table like you can in C: declare Test1 : aliased constant String :=3D "test1"; Test2 : aliased constant String :=3D "test2"; type Table_Type is array (Test_Type) of not null access constant String; Table : constant Table_Type :=3D (T1 =3D> Test1'Access, T2 =3D> Test2'Access, ...); S : String renames Table (Some_Test).all; begin =2E.. end;