comp.lang.ada
 help / color / mirror / Atom feed
From: tonyg <tonythegair@googlemail.com>
Subject: Re: Hexadecimal and stream element arrays
Date: Mon, 19 Apr 2010 10:55:56 -0700 (PDT)
Date: 2010-04-19T10:55:56-07:00	[thread overview]
Message-ID: <d2dcee02-0553-4951-9d56-4c854886dea6@u34g2000yqu.googlegroups.com> (raw)
In-Reply-To: 13872qpzb35yu$.9mbqdk8efq0p.dlg@40tude.net

On Apr 19, 6:27 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Mon, 19 Apr 2010 08:58:16 -0700 (PDT), tonyg wrote:
> > On Apr 19, 4:44 pm, tonyg <tonytheg...@googlemail.com> wrote:
> >> I have some data coming in from a serial port which I want to convert
> >> to hexadecimal and display on the screen. I was wondering if anyone
> >> knows of a simple way to do this?
>
> > To make myself more clear I have already dealt with the serial comms
> > bit, I am looking to display the stream I have already captured
>
> The following is based on:
>
>    http://www.dmitry-kazakov.de/ada/strings_edit.htm
>
> with Ada.Streams;            use Ada.Streams;
> with Strings_Edit;           use Strings_Edit;
> with Strings_Edit.Integers;  use Strings_Edit.Integers;
>
> function Image (Data : Stream_Element_Array) return String is
> begin
>    if Data'Length = 0 then
>       return "";
>    end if;
>    declare
>       Text    : String (1..Data'Length * 3);
>       Pointer : Integer := 1;
>    begin
>       for I in Data'Range loop
>          Put
>          (  Text, Pointer, Stream_Element'Pos (Data (I)),
>             Field=>2, Fill=>'0', Justify=>Right, Base=>16
>          );
>          Put (Text, Pointer, ' ');
>       end loop;
>       return Text (1..Text'Last - 1);
>    end;
> end Image;
>
> An individual item is output
>
>    Put
>    (  Text, Pointer, Stream_Element'Pos (Item),
>        Field=>2, Fill=>'0', Justify=>Right, Base=>16
>    );
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de

Thanks Guys, I forgot how helpful these forums were and how many
people out there used Ada, you reminded me, and I got some working
code \o/



  reply	other threads:[~2010-04-19 17:55 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-19 15:44 Hexadecimal and stream element arrays tonyg
2010-04-19 15:58 ` tonyg
2010-04-19 16:24   ` Ludovic Brenta
2010-04-19 16:27     ` tonyg
2010-04-19 17:02       ` tonyg
2010-04-19 17:26         ` tonyg
2010-04-19 20:50           ` Ludovic Brenta
2010-04-20  9:00             ` tonyg
2010-04-20  9:25               ` Peter Hermann
2010-04-19 18:05     ` Warren
2010-04-19 19:21       ` Jeffrey R. Carter
2010-04-19 19:28         ` Warren
2010-04-19 23:21           ` John B. Matthews
2010-04-19 23:22           ` Adam Beneschan
2010-04-20 14:04             ` Warren
2010-04-20 14:46               ` J-P. Rosen
2010-04-20 15:52                 ` Warren
2010-04-19 19:17     ` Jeffrey R. Carter
2010-04-19 20:52       ` Ludovic Brenta
2010-04-19 23:34         ` Jeffrey R. Carter
2010-04-19 17:20   ` John B. Matthews
2010-04-19 17:27   ` Dmitry A. Kazakov
2010-04-19 17:55     ` tonyg [this message]
2010-04-20  7:25 ` Stephen Leake
2010-04-20 22:21   ` Jeffrey R. Carter
2010-04-21 12:38     ` Stephen Leake
replies disabled

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