comp.lang.ada
 help / color / mirror / Atom feed
From: robert_dewar@my-dejanews.com
Subject: Re: Putting a 'Duration' on the screen ?
Date: 1999/01/18
Date: 1999-01-18T00:00:00+00:00	[thread overview]
Message-ID: <780aj4$eh7$1@nnrp1.dejanews.com> (raw)
In-Reply-To: 36A37529.69BFB3FF@cs.kuleuven.ac.be

In article <36A37529.69BFB3FF@cs.kuleuven.ac.be>,
  Emmanuel Lambert <Emmanuel.Lambert@cs.kuleuven.ac.be>
wrote:
> Hi,
>
> I am freaking out because I would like to output a
> variable from type Duration to the screen, but it does
> not work with put(...). I have included
> Ada.Float_Text_Io, but that does not help. Can someone
> give me a hint. I a unable to find good documentation on
> this.


Emmanuel, so that you may avoid freaking in the future,
let's help you to figure out how to find your own answer
next time :-)

First, look up type Duration in the reference manual, a
little searching in the RM (I always use the ASCII version
it is easier for me to search) finds:

  7   There is a predefined fixed point type named
      Duration, declared in the visible part of package
      Standard;

Ah ha! A *fixed point* type not a *floating point* type.
A little more spelunking around in Text_IO digs up:

68     generic
          type Num is delta <>;
       package Fixed_IO is

71        procedure Put(File : in File_Type;
                        Item : in Num;
                        Fore : in Field := Default_Fore;
                        Aft  : in Field := Default_Aft;
                        Exp  : in Field := Default_Exp);


and if you know how to use generics you are pretty much
home free now. But actually there is an even easier way,
and here again is how you could find this. Look up
operations on a fixed point type, and you will find the
Image attribute, just what the doctor ordered, now you
can do

   Put_Line (Duration'Image (xxx));

which is probably good enough for what you want, though
you don't have control over the format as you do with
Text_IO.

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    




  parent reply	other threads:[~1999-01-18  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-01-18  0:00 Putting a 'Duration' on the screen ? Emmanuel Lambert
1999-01-18  0:00 ` Marin David Condic
1999-01-18  0:00   ` David C. Hoos, Sr.
1999-01-18  0:00     ` Marin David Condic
1999-01-18  0:00 ` Steve O'Neill
1999-01-19  0:00   ` Matthew Heaney
1999-01-18  0:00 ` Tom Moran
1999-01-18  0:00 ` robert_dewar [this message]
1999-01-18  0:00 ` Emmanuel Lambert
replies disabled

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