comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: How to get this space away?
Date: Mon, 08 Jun 2015 13:25:18 -0700
Date: 2015-06-08T13:25:18-07:00	[thread overview]
Message-ID: <ml4tl3$ln3$2@dont-email.me> (raw)
In-Reply-To: <ml4rgr$la5$1@loke.gir.dk>

On 06/08/2015 12:47 PM, Randy Brukardt wrote:
> 
> declare
>     A_Img : constant String := Byte'Image(IP.A);
>     B_Img : constant String := Byte'Image(IP.B);
>     C_Img : constant String := Byte'Image(IP.C);
>     D_Img : constant String := Byte'Image(IP.D);
> begin
>     Put (A_Img(2..A_Img'Last) & '.' & B_Img(2..B_Img'Last) & '.' & 
> C_Img(2..C_Img'Last) & '.' & C_Img(2..C_Img'Last);
> end;

I think you have C_Img in there twice.

> Now, if you prefer to have each part to take up three characters with 
> leading zeros except for the first (so they're all the same length) --  
> that'll take a bit more than a handful of lines in Ada. Ada's formatting is 
> primitive, except in the rarely thought of Annex F (does anyone use that?).

Presuming that "except for the first" means that IP.A should take up the minimum
number of characters, as above:

declare
   function Image is new PragmARC.Images.Modular_Image (Number => Byte);
begin
   Put (Image (IP.A)                                  & '.' &
        Image (IP.B, Width => 3, Zero_Filled => True) & '.' &
        Image (IP.C, Width => 3, Zero_Filled => True) & '.' &
        Image (IP.D, Width => 3, Zero_Filled => True) );
end;

And if you want IP.A to be 3 characters, zero filled, that's easy, too.

-- 
Jeff Carter
"This scene's supposed to be in a saloon, but
the censor cut it out. It'll play just as well
this way." [in a soda fountain]
Never Give a Sucker an Even Break
113


  reply	other threads:[~2015-06-08 20:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 20:32 How to get this space away? Laurent
2015-06-02 20:53 ` Simon Wright
2015-06-03 18:59   ` Laurent
2015-06-03 19:30     ` Simon Wright
2015-06-02 22:28 ` Jeffrey R. Carter
2015-06-03 19:07   ` Laurent
2015-06-03 20:50     ` J-P. Rosen
2015-06-03 23:00       ` Randy Brukardt
2015-06-05  9:26         ` Stephen Davies
2015-06-08 12:33         ` Brad Moore
2015-06-08 19:47           ` Randy Brukardt
2015-06-08 20:25             ` Jeffrey R. Carter [this message]
2015-06-09 14:38               ` Brad Moore
2015-06-04  9:37       ` Georg Bauhaus
2015-06-04 12:32         ` Dmitry A. Kazakov
2015-06-05 13:02       ` Laurent
2015-06-06  0:02         ` Dennis Lee Bieber
2015-06-03  7:28 ` Dmitry A. Kazakov
2015-06-03 19:19   ` Laurent
2015-06-08 22:43 ` wowwomenonwheels205
replies disabled

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