comp.lang.ada
 help / color / mirror / Atom feed
* How to convert an integer to a string??
@ 1996-04-04  0:00 Tony Macrellis
  1996-04-04  0:00 ` Greg Bond
  0 siblings, 1 reply; 2+ messages in thread
From: Tony Macrellis @ 1996-04-04  0:00 UTC (permalink / raw)


I'm a newbie to ada and need some help!  How do I convert an 
integer to a string?

Please reply directly.

Cheers,
Tony Macrellis
(tmacrell@awadi.com.au)




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

* Re: How to convert an integer to a string??
  1996-04-04  0:00 How to convert an integer to a string?? Tony Macrellis
@ 1996-04-04  0:00 ` Greg Bond
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Bond @ 1996-04-04  0:00 UTC (permalink / raw)
  To: Tony Macrellis

Tony Macrellis wrote:
> 
> I'm a newbie to ada and need some help!  How do I convert an
> integer to a string?

Good question in light of the inadequate coverage of I/O issues in the 
Barnes Ada 95 text (pet peeve!). I discovered the following short-cut in 
the Ada95 for C/C++ on-line guide at  

http://lglwww.epfl.ch:80/Ada/Ammo/Cplpl2Ada.html

"A simple program below uses Text_IO to print a message to the screen, 
including numerics!
These are achieved by using the types attribute 'Image which gives back 
a String representation of
a value. 

with Ada.Text_IO; use Ada.Text_IO;
procedure Test_IO is
begin
  Put_Line("Test Starts Here >");
  Put_Line("Integer is " & Integer'Image(2));
  Put_Line("Float is   " & Float'Image(2.0));
  Put_Line("Test Ends Here");
end Test_IO;

It is also possible to use one of the generic child packages of Ada. 
Text_IO such as
Ada.Text_IO.Integer_IO which can be instantiated with a particular type 
to provide type safe
textual IO. 

with Ada.Text_IO; 

type My_Integer is new Integer;

package My_Integer_IO is new Ada.Text_IO.Integer_IO(My_Integer);
use My_Integer_IO;



--
* Greg Bond                         * Dept. of Electrical Eng.  
* email: bond@ee.ubc.ca             * Univ. of British Columbia      
* voice: (604) 822 0899             * 2356 Main Mall                 
* fax:   (604) 822 5949             * Vancouver, BC              
* web: http://www.ee.ubc.ca/~bond   * Canada, V6T 1Z4




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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-04-04  0:00 How to convert an integer to a string?? Tony Macrellis
1996-04-04  0:00 ` Greg Bond

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