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,c58a5b8372dc24a0 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!news.net.uni-c.dk!dotsrc.org!filter.dotsrc.org!news.dotsrc.org!not-for-mail Date: Sat, 17 Apr 2010 19:42:54 +0200 From: =?ISO-8859-1?Q?Thomas_L=F8cke?= <"tl at ada-dk.org"> Organization: Ada DK User-Agent: Thunderbird 2.0.0.23 (X11/20090812) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: confusion with string initialization References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Message-ID: <4bc9f31e$0$272$14726298@news.sunsite.dk> NNTP-Posting-Host: 83.91.213.86 X-Trace: news.sunsite.dk DXC=K6g8EFdPQURbD]FUj;YcCZYSB=nbEKnk[Mc>D_SZ`hh]W1H7KFB`P_Sj<6O5AZ58U]]CDY[=VZ7PSVSiCS>Nm?GR3ASHbgM;6hQ03D`;QO^I9S X-Complaints-To: staff@sunsite.dk Xref: g2news1.google.com comp.lang.ada:10044 Date: 2010-04-17T19:42:54+02:00 List-Id: brett wrote: > I'm trying to learn Ada 2005 with GNAT ( Linux) and are having problems with string initialization using the > > bs := 20 * " "; > > construct, which always gives an error > > "universal integer expected" > > As my syntax is similar to that in Ada 2005 book by Barnes > (page 594 & 596) I'm a bit confused :-) > Searching the ARM was of no value either ! > > Thanks for any input Hey Brett, Here's how the complete example from the excellent John Barnes book could look: with Ada.Strings.Bounded; use Ada.Strings.Bounded; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO.Bounded_IO; with Ada.Strings.Unbounded.Text_IO; use Ada.Strings.Unbounded.Text_IO; procedure String_Test is package Bounded_80 is new Generic_Bounded_Length (80); use Bounded_80; package Bounded_80_IO is new Bounded_IO (Bounded_80); use Bounded_80_IO; BS : Bounded_String; US : Unbounded_String; S15 : String (1 .. 15); begin BS := 2 * "Bar"; Put_Line (BS); US := 3 * 'A'; Put_Line (US); US := 2 * US; Put_Line (US); S15 := 5 * "SOS"; Put_Line (S15); end String_Test; And here's the output you should get when executing the program: BarBar AAA AAAAAA SOSSOSSOSSOSSOS -- Regards, Thomas L�cke Email: tl at ada-dk.org Web: http:ada-dk.org IRC nick: ThomasLocke