comp.lang.ada
 help / color / mirror / Atom feed
* Help on Package_Name
@ 2004-11-21 16:59 19owls
  2004-11-21 17:33 ` Ludovic Brenta
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: 19owls @ 2004-11-21 16:59 UTC (permalink / raw)


Hi. It's my first day with Ada. heard many wonderful things about it.
i'm not studying programming, but i've done basic C before.
obviously i've read and managed to compile the infamous
Hello World!

i have a beginners book on Ada, it keeps referring to student_io package
name for the exercises and examples which is not known to gnat. i need to
know what package name to use whilst handling text, calculations,strings
and so on beyond text_io (which handles strings only i suppose).

in future how do i know of the list of package names to use and what it is
for? thanks.



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

* Re: Help on Package_Name
  2004-11-21 16:59 Help on Package_Name 19owls
@ 2004-11-21 17:33 ` Ludovic Brenta
  2004-11-22 16:16 ` munnoch
  2004-11-22 23:07 ` David Botton
  2 siblings, 0 replies; 9+ messages in thread
From: Ludovic Brenta @ 2004-11-21 17:33 UTC (permalink / raw)


19owls writes:
> Hi. It's my first day with Ada. heard many wonderful things about
> it.  i'm not studying programming, but i've done basic C before.
> obviously i've read and managed to compile the infamous Hello World!

Welcome to Ada!

> i have a beginners book on Ada, it keeps referring to student_io
> package name for the exercises and examples which is not known to
> gnat. i need to know what package name to use whilst handling text,
> calculations,strings and so on beyond text_io (which handles strings
> only i suppose).

For most purposes, Ada.Text_IO is sufficient if you combine it with
the attributes 'Image and 'Value.  These are attributes of all scalar
types (numbers and enumerations).  They allow you to convert back and
forth between the scalar type and a string.  For example:

with Ada.Text_IO;
procedure Hello_Numeric is
   Age : Integer;
   A_String : String (1 .. 20);
   Last : Natural;
begin
   -- From Integer to String:
   Ada.Text_IO.Put_Line ("The Answer is " & Integer'Image (42));
   Ada.Text_IO.Put ("What is you age? ");
   Ada.Text_IO.Get_Line (A_String, Last);
   -- from String to Integer:
   Age := Integer'Value (A_String (1 .. Last));
end Hello_Numeric;

There is also a package named Ada.Integer_Text_IO for Integers.
amongst other things, this package allows you to read Integers from
the command line, e.g.

with Ada.Text_IO;
with Ada.Integer_Text_IO;
procedure Hello_Numeric is
   Age : Integer;
begin
   Ada.Text_IO.Put_Line ("The Answer is " & Integer'Image (42));
   Ada.Text_IO.Put ("What is you age? ");
   Ada.Integer_Text_IO.Get (Age);
end Hello_Numeric;

Once you learn about generics, you will also learn how to create new
packages for your own types, e.g. enumerations.  But I suggest you
stick with Ada.Text_IO and Ada.Integer_Text_IO until you reach that
chapter.

> in future how do i know of the list of package names to use and what
> it is for? thanks.

Good question.  The definitive source is the Ada Reference Manual:

http://www.adaic.org/standards/ada95.html

Annex A "Predefined Environment" of the ARM has a list of all
predefined packages, as well as the complete specification of their
contents.  Ada.Text_IO and Ada.Integer_Text_IO are defined there.

Student_IO is obviously not part of the predefined environment; it
seems to have been written by a teacher for the purposes of his or her
course.  Perhaps the full contents of Student_IO are in an appendix in
your book?  If so, you can type it into student_io.ads (specification)
and student_io.adb (body) so that GNAT knows about it.  If you do not
have the full source to Student_IO, I suggest you try another book.
There are several beginners' books about Ada on the Ada Information
Clearinghouse; they either do not depend on nonstandard packages, or
provide the full sources:

http://www.adaic.org/learn/textbook.html

For beginners, I recommend "Ada 95: The Craft of Object-Oriented
Programming" by John English.

HTH

-- 
Ludovic Brenta.



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

* Re: Help on Package_Name
  2004-11-21 16:59 Help on Package_Name 19owls
  2004-11-21 17:33 ` Ludovic Brenta
@ 2004-11-22 16:16 ` munnoch
  2004-11-22 19:17   ` Jeffrey Carter
  2004-11-23  4:45   ` 19owls
  2004-11-22 23:07 ` David Botton
  2 siblings, 2 replies; 9+ messages in thread
From: munnoch @ 2004-11-22 16:16 UTC (permalink / raw)


=) first question i might just be able to help on ...
you said you're using the GNAT compiler - this is good, since i know the 
folder where the standard package files are stored;
the default is (for Windows at least):
C:\GNAT\lib\gcc-lib\pentium-mingw32msv\2.8.1\adainclude
the only slight problem is that the filenames are a bit cryptic - BUT you 
have the ability now to browse through ALL the standard specification files 
for the packages at leisure (you may want to check up some on packages from 
your book beforehand, and if the book has nothing on packages, get a new 
book - i am using ADA95 The craft of object oriented programming by John 
English ...
mostly because the book is available for free from the following webaddress
http://www.it.bton.ac.uk/staff/je/adacraft/
for my ADA studies.
(the same guy also does a newbies GUI programming package called JEWL, 
kindly pointed out to me a few days ago on here, thanks again to those guys 
=)

The main standard packages i find myself (also newbie programmer) using are 
(not a comprehensive listing though):
ada.text_io
ada.integer_text_io
ada.float_text_io

ada.text_io deals with character input - this includes strings which are 
just arrays of characters
and .. well .. you guessed it .. ada.integer_text_io and ada.float_text_io 
deals with integer and floating point number types respectively

hope this helped =)


"19owls" <19@owls.org> wrote in message 
news:pan.2004.11.21.16.59.26.803863@owls.org...
> Hi. It's my first day with Ada. heard many wonderful things about it.
> i'm not studying programming, but i've done basic C before.
> obviously i've read and managed to compile the infamous
> Hello World!
>
> i have a beginners book on Ada, it keeps referring to student_io package
> name for the exercises and examples which is not known to gnat. i need to
> know what package name to use whilst handling text, calculations,strings
> and so on beyond text_io (which handles strings only i suppose).
>
> in future how do i know of the list of package names to use and what it is
> for? thanks. 





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

* Re: Help on Package_Name
  2004-11-22 16:16 ` munnoch
@ 2004-11-22 19:17   ` Jeffrey Carter
  2004-11-23 23:43     ` munnoch
  2004-11-23  4:45   ` 19owls
  1 sibling, 1 reply; 9+ messages in thread
From: Jeffrey Carter @ 2004-11-22 19:17 UTC (permalink / raw)


munnoch wrote:

> ada.text_io deals with character input - this includes strings which are 
> just arrays of characters
> and .. well .. you guessed it .. ada.integer_text_io and ada.float_text_io 
> deals with integer and floating point number types respectively

No, Ada.Integer_Text_IO deals with I/O for type Integer and 
Ada.Float_Text_IO for type Float. These are essentially instantiations 
of Ada.Text_IO.Integer_IO for type Integer and Ada.Text_IO.Float_IO for 
type Float. As a beginner, you may well just use Integer and Float in 
your early programs, but once you've learned the language and for 
anything that matters, you should be declaring your own numeric types.

I know the terminology is a little confusing. Ada.Text_IO.Integer_IO 
provides text I/O for any [signed] integer type. Type Integer is one 
such type. Similarly, Ada.Text_IO.Float_IO provides text I/O for any 
floating-point type; type Float is one such type.

-- 
Jeff Carter
"People called Romanes, they go the house?"
Monty Python's Life of Brian
79




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

* Re: Help on Package_Name
  2004-11-21 16:59 Help on Package_Name 19owls
  2004-11-21 17:33 ` Ludovic Brenta
  2004-11-22 16:16 ` munnoch
@ 2004-11-22 23:07 ` David Botton
  2 siblings, 0 replies; 9+ messages in thread
From: David Botton @ 2004-11-22 23:07 UTC (permalink / raw)


I recommend to help you get started to take a look at http://www.adapower.com

You will find the Ada FAQ there, free Ada books, and the Source Code 
Treasury with examples of how to do various tasks in Ada.

The student_io package is a package provided by the author of the book 
you are using. See if it came with a CD.

David Botton
http://www.adapower.com


On 2004-11-21 11:59:27 -0500, 19owls <19@owls.org> said:

> Hi. It's my first day with Ada. heard many wonderful things about it.
> i'm not studying programming, but i've done basic C before.
> obviously i've read and managed to compile the infamous
> Hello World!
> 
> i have a beginners book on Ada, it keeps referring to student_io package
> name for the exercises and examples which is not known to gnat. i need to
> know what package name to use whilst handling text, calculations,strings
> and so on beyond text_io (which handles strings only i suppose).
> 
> in future how do i know of the list of package names to use and what it is
> for? thanks.





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

* Re: Help on Package_Name
  2004-11-22 16:16 ` munnoch
  2004-11-22 19:17   ` Jeffrey Carter
@ 2004-11-23  4:45   ` 19owls
  2004-11-23 10:17     ` Marius Amado Alves
  1 sibling, 1 reply; 9+ messages in thread
From: 19owls @ 2004-11-23  4:45 UTC (permalink / raw)


Thanks

i found this on the web so i think it's closest to the student_io i was
looking for for the time being
http://www.adaworks.com/standard_io.htm

anyway, i'm running linux Fedora with a gnat compiler and i also found
where they keep the libraries for ada. so now i know where to keep my
package files. the book i had was from a library so there's no CDrom with
it and it's really old (1985)

Adacraft looks good. for the meantime, i'd just have to read up and be
versed with the packages to use or create so that i can learn further.

Regards


--  Can't you read?  --19 --

> =) first question i might just be able to help on ...
> you said you're using the GNAT compiler - this is good, since i know the 
> folder where the standard package files are stored;
> the default is (for Windows at least):
> C:\GNAT\lib\gcc-lib\pentium-mingw32msv\2.8.1\adainclude
> the only slight problem is that the filenames are a bit cryptic - BUT you 
> have the ability now to browse through ALL the standard specification files 
> for the packages at leisure (you may want to check up some on packages from 
> your book beforehand, and if the book has nothing on packages, get a new 
> book - i am using ADA95 The craft of object oriented programming by John 
> English ...
> mostly because the book is available for free from the following webaddress
> http://www.it.bton.ac.uk/staff/je/adacraft/
> for my ADA studies.
> (the same guy also does a newbies GUI programming package called JEWL, 
> kindly pointed out to me a few days ago on here, thanks again to those guys 
> =)
> 
> The main standard packages i find myself (also newbie programmer) using are 
> (not a comprehensive listing though):
> ada.text_io
> ada.integer_text_io
> ada.float_text_io
> 
> ada.text_io deals with character input - this includes strings which are 
> just arrays of characters
> and .. well .. you guessed it .. ada.integer_text_io and ada.float_text_io 
> deals with integer and floating point number types respectively
> 
> hope this helped =)
> 
> 
> "19owls" <19@owls.org> wrote in message 
> news:pan.2004.11.21.16.59.26.803863@owls.org...
>> Hi. It's my first day with Ada. heard many wonderful things about it.
>> i'm not studying programming, but i've done basic C before.
>> obviously i've read and managed to compile the infamous
>> Hello World!
>>
>> i have a beginners book on Ada, it keeps referring to student_io package
>> name for the exercises and examples which is not known to gnat. i need to
>> know what package name to use whilst handling text, calculations,strings
>> and so on beyond text_io (which handles strings only i suppose).
>>
>> in future how do i know of the list of package names to use and what it is
>> for? thanks.




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

* Re: Help on Package_Name
  2004-11-23  4:45   ` 19owls
@ 2004-11-23 10:17     ` Marius Amado Alves
  2004-11-23 10:41       ` 19owls
  0 siblings, 1 reply; 9+ messages in thread
From: Marius Amado Alves @ 2004-11-23 10:17 UTC (permalink / raw)
  To: comp.lang.ada

19owls wrote:
> i found this on the web so i think it's closest to the student_io i was
> looking for for the time being
> http://www.adaworks.com/standard_io.htm

You cannot substitute packages at will! Fortunately most probably the 
compiler will not let you.

> anyway, i'm running linux Fedora with a gnat compiler and i also found
> where they keep the libraries for ada. so now i know where to keep my
> package files.

You don't have to put it there, and surely you don't--and should 
not--"learn" Ada from how a compiler manages its files. There is 
absolutely no black art with Ada. Everything you need to--and 
shoudld--know is fully documented. Usually you create a directory for 
your files, and work there, invoke the compiler from there, and the 
compiler finds your units there. If the compiler does not find the 
standard units then it is not well installed.

> the book i had was from a library so there's no CDrom with
> it and it's really old (1985)
> Adacraft looks good. for the meantime, i'd just have to read up and be
> versed with the packages to use or create so that i can learn further.

Yes, use an uncrippled resource.




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

* Re: Help on Package_Name
  2004-11-23 10:17     ` Marius Amado Alves
@ 2004-11-23 10:41       ` 19owls
  0 siblings, 0 replies; 9+ messages in thread
From: 19owls @ 2004-11-23 10:41 UTC (permalink / raw)


i am working within my own directory. good to know that my compiler works
within the compiling directory too. thanks

i got hold of a newer book which of great help briefing me on
standard packages and how to declare packages that i need.

--  Can't you read?  --19 --

> 19owls wrote:
>> i found this on the web so i think it's closest to the student_io i was
>> looking for for the time being
>> http://www.adaworks.com/standard_io.htm
> 
> You cannot substitute packages at will! Fortunately most probably the 
> compiler will not let you.
> 
>> anyway, i'm running linux Fedora with a gnat compiler and i also found
>> where they keep the libraries for ada. so now i know where to keep my
>> package files.
> 
> You don't have to put it there, and surely you don't--and should 
> not--"learn" Ada from how a compiler manages its files. There is 
> absolutely no black art with Ada. Everything you need to--and 
> shoudld--know is fully documented. Usually you create a directory for 
> your files, and work there, invoke the compiler from there, and the 
> compiler finds your units there. If the compiler does not find the 
> standard units then it is not well installed.
> 
>> the book i had was from a library so there's no CDrom with
>> it and it's really old (1985)
>> Adacraft looks good. for the meantime, i'd just have to read up and be
>> versed with the packages to use or create so that i can learn further.
> 
> Yes, use an uncrippled resource.




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

* Re: Help on Package_Name
  2004-11-22 19:17   ` Jeffrey Carter
@ 2004-11-23 23:43     ` munnoch
  0 siblings, 0 replies; 9+ messages in thread
From: munnoch @ 2004-11-23 23:43 UTC (permalink / raw)


Ok, my mistake - I should leave help commentary to the pro's
and stick to asking my mundane questions =)


"Jeffrey Carter" <spam@spam.com> wrote in message 
news:sXqod.2270$uV6.2094@newsread3.news.pas.earthlink.net...
> munnoch wrote:
>
>> ada.text_io deals with character input - this includes strings which are 
>> just arrays of characters
>> and .. well .. you guessed it .. ada.integer_text_io and 
>> ada.float_text_io deals with integer and floating point number types 
>> respectively
>
> No, Ada.Integer_Text_IO deals with I/O for type Integer and 
> Ada.Float_Text_IO for type Float. These are essentially instantiations of 
> Ada.Text_IO.Integer_IO for type Integer and Ada.Text_IO.Float_IO for type 
> Float. As a beginner, you may well just use Integer and Float in your 
> early programs, but once you've learned the language and for anything that 
> matters, you should be declaring your own numeric types.
>
> I know the terminology is a little confusing. Ada.Text_IO.Integer_IO 
> provides text I/O for any [signed] integer type. Type Integer is one such 
> type. Similarly, Ada.Text_IO.Float_IO provides text I/O for any 
> floating-point type; type Float is one such type.
>
> -- 
> Jeff Carter
> "People called Romanes, they go the house?"
> Monty Python's Life of Brian
> 79
> 





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

end of thread, other threads:[~2004-11-23 23:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-21 16:59 Help on Package_Name 19owls
2004-11-21 17:33 ` Ludovic Brenta
2004-11-22 16:16 ` munnoch
2004-11-22 19:17   ` Jeffrey Carter
2004-11-23 23:43     ` munnoch
2004-11-23  4:45   ` 19owls
2004-11-23 10:17     ` Marius Amado Alves
2004-11-23 10:41       ` 19owls
2004-11-22 23:07 ` David Botton

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