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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,18f7cf743c6dec5 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-21 12:12:07 PST Path: supernews.google.com!sn-xit-03!supernews.com!cyclone-sjo1.usenetserver.com!news-out.usenetserver.com!ptdnetP!newsgate.ptd.net!attmtf.ip.att.net!attor2!ip.att.net!news.hitter.net!news!news.crc.com!not-for-mail From: "David C. Hoos, Sr." Newsgroups: comp.lang.ada Subject: Re: Strings Date: Thu, 21 Dec 2000 13:03:29 -0600 Organization: CRC: A wholly owned subsidiary of Thermo Electron Message-ID: <91tk4g$aih$1@hobbes2.crc.com> References: <3A42418F.ACCD532A@vdu.org> NNTP-Posting-Host: 198.175.145.56 X-Trace: hobbes2.crc.com 977425360 10833 198.175.145.56 (21 Dec 2000 19:02:40 GMT) X-Complaints-To: abuse@crc.com NNTP-Posting-Date: 21 Dec 2000 19:02:40 GMT X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Xref: supernews.google.com comp.lang.ada:3334 Date: 2000-12-21T19:02:40+00:00 List-Id: Your problem is that Ada.Strings.Bounded.Generic_Bounded_Length is a generic _package_, not a type. An instantiation of that _package_ exports a type Bounded_String. So, if in your original example, you substitute package Bounded_80 is new ... for type Bounded_80 is new ... everything will work as expected. "Jef Kelmo" wrote in message news:3A42418F.ACCD532A@vdu.org... > Hello, > > This is not a homework question. In 5 months, I will begin work that > uses Ada and am trying to become familiar with it now. But I am having a > problem with how to use strings; a problem that seems common across a > number of languages, including C++ and Java. > > I entered the following... > > -------------------------------------------------------------------------- -------------------------------- > > with Ada.Text_IO; > with Ada.Strings.Bounded; > > procedure My_Strings is > type Bounded_80 is new > Ada.Strings.Bounded.Generic_Bounded_Length(80); > > a1 : Bounded_80.Bounded_String := Bounded_80.To_Bounded_String("Some > Text"); > > begin > Ada.Text_IO.Put(Bounded_80.To_String(a1)); > Ada.Text_IO.New_Line; > > end My_Strings; > -------------------------------------------------------------------------- -------------------------------- > > ...and when I compile, I get the following... > > gcc -c my_strings.adb > my_strings.adb:5:47: subtype mark required in this context > my_strings.adb:5:70: incorrect constraint for this kind of type > my_strings.adb:7:10: invalid prefix in selected component "Bounded_80" > my_strings.adb:7:39: invalid prefix in selected component "Bounded_80" > my_strings.adb:12:21: invalid prefix in selected component "Bounded_80" > gnatmake: "my_strings.adb" compilation error > > > So my first guess is to change... > > type Bounded_80 is new > Ada.Strings.Bounded.Generic_Bounded_Length(80); > > ...to... > > subtype Bounded_80 is new > Ada.Strings.Bounded.Generic_Bounded_Length(80); > > ...in which case I get... > > gcc -c my_strings.adb > my_strings.adb:5:27: "new" ignored (only allowed in type declaration) > gnatmake: "my_strings.adb" compilation error > > ...so I remove the "new" and get... > > gcc -c my_strings.adb > my_strings.adb:5:46: subtype mark required in this context > my_strings.adb:5:69: incorrect constraint for this kind of type > my_strings.adb:7:10: invalid prefix in selected component "Bounded_80" > my_strings.adb:7:39: invalid prefix in selected component "Bounded_80" > my_strings.adb:12:21: invalid prefix in selected component "Bounded_80" > gnatmake: "my_strings.adb" compilation error > > Is it obvious by now that I don't know what I am doing? I have a > copy of Ada as a 2d Language and I looked up the Ada Reference on > adapower.com, but everything is too vague and anything I try does not > work. > > I just want a usable string. How would I change the above code to do > this? And could someone please point me to a site that gives actual, > concrete examples of simple string use? > > Thanks. > > James > >