From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: buffer2.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!goblin2!goblin.stu.neva.ru!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: How to get this space away? Date: Mon, 08 Jun 2015 13:25:18 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <0b23f4af-9a55-4d1d-be90-f74b316a95cf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 8 Jun 2015 20:24:05 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="a3855fbfe1a666be9aefba0563039ed5"; logging-data="22243"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/++aOaAdUPdB6AaWHbWi8rEY37YkPeeAo=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: Cancel-Lock: sha1:m/WjnwTsTkhUIzeNVTkGgJGPohc= Xref: number.nntp.giganews.com comp.lang.ada:193531 Date: 2015-06-08T13:25:18-07:00 List-Id: 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