comp.lang.ada
 help / color / mirror / Atom feed
* Novice child package question
@ 1997-04-18  0:00 Foucault
  1997-04-18  0:00 ` Jon S Anthony
  0 siblings, 1 reply; 2+ messages in thread
From: Foucault @ 1997-04-18  0:00 UTC (permalink / raw)



Ok I'm pretty new to Ada and I'm trying to access the
functions within the package Ada.Strings.Bounded to use on a
string with a bounded length of 80.  I'm using GNAT3.09 on a intel
system,  when I try to compile this code I get the following errors:

gcc -c -IF:\MYDOCU~1\ADAASS~1\ -I- -x ada
F:\MYDOCU~1\ADAASS~1\STRING.ADB
STRING.ADB:14:11: warning: file name does not match unit name, should
be "usestring.adb"
STRING.ADB:24:04: "Replace_Slice" is not visible
STRING.ADB:24:04: non-visible declaration at a-strbou.ads:283
STRING.ADB:24:04: non-visible declaration at a-strbou.ads:275
STRING.ADB:26:25: "length" is not visible
STRING.ADB:26:25: non-visible declaration at a-strbou.ads:38
gnatmake: "F:\MYDOCU~1\ADAASS~1\STRING.ADB" compilation error

I'm assuming that I need to access the generic  package
ada.strings.bounded_length in order to use the replace_slice procedure
but I have no clue as to how to declare it.

in Cohen's Ada book he gives the following instantiation :
	with Ada.Strings.Bounded;
	package Bounded_80 is
		new Ada.Strings.Bounded.Generic_Bounded_length(80);
But when I put this into my code I get a variety of errors such as
STRING.ADB:15:01: end of file expected, file can have only one
compilation unit

Is there a relatively simple solution to what must be a rather basic
question?
Thanks for any enlightenment bestowed upon me,
	Gregor
My source follows:
____________________________________

WITH Ada.Text_IO;
USE Ada.Text_IO;

WITH Ada.Integer_Text_IO;
USE Ada.Integer_Text_IO;

WITH Ada.Strings;
USE  Ada.Strings;

WITH Ada.Strings.Bounded;
USE  Ada.Strings.Bounded;


Procedure UseString is 
   
   sentence :string(1..80);
   senlength:integer;

Begin
   put_line("Enter a text string:");
   get_line(sentence, senlength);
   put_line(sentence(1..senlength));

   Replace_Slice
        (Sentence, 8,11,"AdA!");
   put_line(sentence(1..senlength));
end UseString;




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Novice child package question
  1997-04-18  0:00 Novice child package question Foucault
@ 1997-04-18  0:00 ` Jon S Anthony
  0 siblings, 0 replies; 2+ messages in thread
From: Jon S Anthony @ 1997-04-18  0:00 UTC (permalink / raw)



In article <3357ac7d.5108745@netnews.worldnet.att.net> draig@ix.netcom.com (Foucault) writes:

> STRING.ADB:14:11: warning: file name does not match unit name, should
> be "usestring.adb"

Unless you request otherwise (see gnatinfo) GNAT wants 1 unit per file
and the name of unit should match the name of the file (or vice-versa).

> Is there a relatively simple solution to what must be a rather basic
> question?

More or less.  Try this:

WITH Ada.Text_IO;
USE Ada.Text_IO;
 
WITH Ada.Integer_Text_IO;
USE Ada.Integer_Text_IO;
 
WITH Ada.Strings;
USE  Ada.Strings;
 
WITH Ada.Strings.Bounded;
USE  Ada.Strings.Bounded;
 
 
Procedure UseString is 
 
   package Bounded_80 is
        new Ada.Strings.Bounded.Generic_Bounded_length(80);
   use Bounded_80;
   
   sentence :string(1..80);
   senlength:integer;
 
Begin
   put_line("Enter a text string:");
   get_line(sentence, senlength);
   put_line(sentence(1..senlength));
 
   Put_Line(To_String(
        Replace_Slice(To_Bounded_String(Sentence(1..Senlength)),
        8,11,"AdA!")));
end UseString;


> Thanks for any enlightenment bestowed upon me,

You're welcome.

/Jon
-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-04-18  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-04-18  0:00 Novice child package question Foucault
1997-04-18  0:00 ` Jon S Anthony

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox