From: Jef Kelmo <jlk@vdu.org>
Subject: Strings
Date: Thu, 21 Dec 2000 17:45:22 GMT
Date: 2000-12-21T17:45:22+00:00 [thread overview]
Message-ID: <3A42418F.ACCD532A@vdu.org> (raw)
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
next reply other threads:[~2000-12-21 17:45 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-12-21 17:45 Jef Kelmo [this message]
2000-12-21 18:01 ` Strings Jef Kelmo
2000-12-21 18:47 ` Strings mark_lundquist
2000-12-21 18:47 ` Strings mark_lundquist
2000-12-21 23:31 ` Strings gdemont
2000-12-21 19:03 ` Strings David C. Hoos, Sr.
-- strict thread matches above, loose matches on Subject: below --
2000-12-21 21:09 Strings Beard, Frank
2000-12-22 14:19 ` Strings Jef Kelmo
2000-12-22 14:49 ` Strings Larry Kilgallen
2000-12-22 16:35 ` Strings Marin David Condic
2000-12-23 21:04 ` Strings Georg Bauhaus
2000-05-27 0:00 Strings Karlene
2000-05-27 0:00 ` Strings Robert Dewar
2000-05-27 0:00 ` Strings David C. Hoos, Sr.
2000-05-27 0:00 ` Strings MaggieJohn
2000-05-28 0:00 ` Strings Robert Dewar
2000-06-03 0:00 ` Strings Robert I. Eachus
2000-05-27 0:00 ` Strings Robert Dewar
1995-01-25 15:08 Strings Ray Toal
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox