comp.lang.ada
 help / color / mirror / Atom feed
From: "Steve" <nospam_steved94@attbi.com>
Subject: Re: Base 12 Integer IO
Date: Tue, 04 Feb 2003 03:37:35 GMT
Date: 2003-02-04T03:37:35+00:00	[thread overview]
Message-ID: <3AG%9.88344$to3.202513@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: mailman.12.1044286941.3911.comp.lang.ada@ada.eu.org


"Paolo Argenton" <paoloa1@yahoo.com> wrote in message
news:mailman.12.1044286941.3911.comp.lang.ada@ada.eu.org...
Hi all !
I would like to do base 12 Integer IO;
while the following code fragment works
   for I in 0..1488 loop
      Put( I, Width => 3, Base => 12 );

It has 2 drawbacks (for me at least)
1) the output is with leading base number and # i.e. 12#A40# while I would
like to have the raw A40, for instance.
2) width is not fixed, i.e. I would like to have in the output 005 for -say-
number 5 instead of one digit only.
How can I fix these things? Can I do Integer IO to a string, in order to
reformat the string as I desire?
Thanks everybody
Paolo

Here is a small example (that runs and produces the correct result):

WITH Ada.Strings.Fixed;
 USE Ada.Strings.Fixed;
WITH Ada.Strings.Maps;
 USE Ada.Strings.Maps;
WITH Ada.Text_Io;
 USE Ada.Text_Io;
WITH Ada.Integer_Text_Io;
 USE Ada.Integer_Text_Io;
PROCEDURE GetNumString IS

  value : Integer := 42;
  buffer : String( 1 .. 32 );
BEGIN
  Put( buffer, value, 12 );
  DECLARE
    lbSet : Character_Set := To_Set( '#' );
    notLb : Character_Set := NOT lbSet;
    text : String := Tail( Trim( Trim( buffer, notLb, notLb ),
                                 lbSet, lbSet), 4, '0' );
  BEGIN
    Put_Line( text );
  END;
END GetNumString;


Yahoo! Cellulari: loghi, suonerie, picture message per il tuo telefonino





  parent reply	other threads:[~2003-02-04  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.12.1044286941.3911.comp.lang.ada@ada.eu.org>
2003-02-03 16:02 ` Base 12 Integer IO Mark Biggar
2003-02-03 16:42 ` Martin Dowie
2003-02-03 18:56 ` Georg Bauhaus
2003-02-04  3:37 ` Steve [this message]
2003-02-04 10:58 ` Dmitry A. Kazakov
replies disabled

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