comp.lang.ada
 help / color / mirror / Atom feed
* BASIC_NUM_IO
@ 2009-06-01  7:57 Georg
  2009-06-01  8:13 ` BASIC_NUM_IO Pascal Obry
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Georg @ 2009-06-01  7:57 UTC (permalink / raw)


Hi All,

in my Ada books I find the with-clause "with BASIC_NUM_IO; use 
BASIC_NUM_IO".

The following program

with basic_num_io; use basic_num_io;

procedure test_ranges is
begin
   put_line(short_integer'size);
end test_ranges;

does not compile because the compiler complaints that the package 
"basic_num_io" does not exist.

Is there a replacement for this package in GNAT? How can I print number 
on the screen instead?

Regards

Georg



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

* Re: BASIC_NUM_IO
  2009-06-01  7:57 BASIC_NUM_IO Georg
@ 2009-06-01  8:13 ` Pascal Obry
  2009-06-01  8:18 ` BASIC_NUM_IO Martin
  2009-06-01  8:18 ` BASIC_NUM_IO anon
  2 siblings, 0 replies; 4+ messages in thread
From: Pascal Obry @ 2009-06-01  8:13 UTC (permalink / raw)
  To: Georg

Georg,

> in my Ada books I find the with-clause "with BASIC_NUM_IO; use 
> BASIC_NUM_IO".

This is not a standard Ada package. It probably comes with the book and
used on the examples.

> The following program
> 
> with basic_num_io; use basic_num_io;
> 
> procedure test_ranges is
> begin
>    put_line(short_integer'size);
> end test_ranges;
> 
> does not compile because the compiler complaints that the package 
> "basic_num_io" does not exist.
> 
> Is there a replacement for this package in GNAT? How can I print number 
> on the screen instead?

Ada.Interger_Text_IO.

Or the generic Ada.Text_IO.Integer_IO that you can instantiate with your
own integer type.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|    http://www.obry.net  -  http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B



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

* Re: BASIC_NUM_IO
  2009-06-01  7:57 BASIC_NUM_IO Georg
  2009-06-01  8:13 ` BASIC_NUM_IO Pascal Obry
@ 2009-06-01  8:18 ` Martin
  2009-06-01  8:18 ` BASIC_NUM_IO anon
  2 siblings, 0 replies; 4+ messages in thread
From: Martin @ 2009-06-01  8:18 UTC (permalink / raw)


On Jun 1, 8:57 am, Georg <nob...@nowhere.com> wrote:
> Hi All,
>
> in my Ada books I find the with-clause "with BASIC_NUM_IO; use
> BASIC_NUM_IO".
>
> The following program
>
> with basic_num_io; use basic_num_io;
>
> procedure test_ranges is
> begin
>    put_line(short_integer'size);
> end test_ranges;
>
> does not compile because the compiler complaints that the package
> "basic_num_io" does not exist.
>
> Is there a replacement for this package in GNAT? How can I print number
> on the screen instead?
>
> Regards
>
> Georg

You could use Ada.Text_IO.Integer_IO and instantiate it with the type
of the data item you want to 'Put_Line'. This gets rather tedious if
you more than 2 types! ;-)

The alternative is to use 'Image, e.g.

with Ada.Text_IO; use Ada.Text_IO;
procedure Demo is
   I : Integer := 42;
begin
   Put_Line (Integer'Image (I));
end Demo;

The return type from 'Size if 'universal_integer' and you can't say
"universal_integer'Image (...") but luckily enough an "Integer'Image
(...)" will work for that.

Cheers
-- Martin




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

* Re: BASIC_NUM_IO
  2009-06-01  7:57 BASIC_NUM_IO Georg
  2009-06-01  8:13 ` BASIC_NUM_IO Pascal Obry
  2009-06-01  8:18 ` BASIC_NUM_IO Martin
@ 2009-06-01  8:18 ` anon
  2 siblings, 0 replies; 4+ messages in thread
From: anon @ 2009-06-01  8:18 UTC (permalink / raw)


"Ada.Integer_Text_IO" is the standard package that most use for integer I/O

with Ada.Text_IO ;   -- use for "new_line" 
use  Ada.Text_IO ;

with Ada.Integer_Text_IO ; -- use for integer "put" 
use  Ada.Integer_Text_IO ;

procedure test_ranges is
begin
  put ( short_integer'size ) ;
  new_line ;
end test_ranges ;


If you want to define your own type of integer  then 

with Ada.Text_IO ;   -- use for new_line 
use  Ada.Text_IO ;

procedure test_ranges is

  package basic_num_io is new Ada.Text_IO.Integer_IO ( Integer ) ;
  use basic_num_io ; 

begin
  put ( short_integer'size ) ;
  new_line ;
end test_ranges ;

In <78hfulF1m321pU2@mid.individual.net>, Georg <nobody@nowhere.com> writes:
>Hi All,
>
>in my Ada books I find the with-clause "with BASIC_NUM_IO; use 
>BASIC_NUM_IO".
>
>The following program
>
>with basic_num_io; use basic_num_io;
>
>procedure test_ranges is
>begin
>   put_line(short_integer'size);
>end test_ranges;
>
>does not compile because the compiler complaints that the package 
>"basic_num_io" does not exist.
>
>Is there a replacement for this package in GNAT? How can I print number 
>on the screen instead?
>
>Regards
>
>Georg




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

end of thread, other threads:[~2009-06-01  8:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-01  7:57 BASIC_NUM_IO Georg
2009-06-01  8:13 ` BASIC_NUM_IO Pascal Obry
2009-06-01  8:18 ` BASIC_NUM_IO Martin
2009-06-01  8:18 ` BASIC_NUM_IO anon

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