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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.velia.net!noris.net!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: String declaration and initialization Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: Date: Thu, 22 May 2008 18:05:50 +0200 Message-ID: <1sx14jlsjttyu$.me8s3y39ipru.dlg@40tude.net> NNTP-Posting-Date: 22 May 2008 18:05:50 CEST NNTP-Posting-Host: 19983451.newsspool4.arcor-online.net X-Trace: DXC=moR=_G?_8e_U6b:FjPaGjQ4IUK_7mdaO__l\719ZmU7R X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:288 Date: 2008-05-22T18:05:50+02:00 List-Id: 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