From: romans_paula@hotmail.com (Paula)
Subject: Re: New to Ada..need some help regarding Binary Conversion??
Date: 16 Oct 2002 04:09:39 -0700
Date: 2002-10-16T11:09:40+00:00 [thread overview]
Message-ID: <4ee1d187.0210160309.73648bd1@posting.google.com> (raw)
In-Reply-To: mailman.1034704382.5852.comp.lang.ada@ada.eu.org
sk <noname@myob.com> wrote in message news:<mailman.1034704382.5852.comp.lang.ada@ada.eu.org>...
> Hi,
>
> Pipes ?
>
> -----------------------
> Test file (hello-txt)
> -----------------------
> Hello (contents of piped test file).
>
> ------------
> Ada source
> ------------
> with Ada.Text_Io;
>
> procedure Print_Pipe is
>
> package TIO renames Ada.Text_Io;
>
> Char : Character;
>
> begin
> loop
> -- Explicit mention of "Standard_Input" and
> -- "Standard_Output" to document ...
>
> exit when TIO.End_Of_File (TIO.Standard_Input);
>
> TIO.Get (TIO.Standard_Input, Char);
>
> TIO.Put (TIO.Standard_Output, Char);
>
> end loop;
>
> end Print_Pipe;
>
> --------------------------
> -- Command line (Linux) --
> --------------------------
>
> $ cat hello-txt | print_pipe
> Hello (contents of piped test file).
>
>
> For your particular criteria (16-bit data), define
> your 16-bit data type, use Ada.Text_Io.Text_Streams
> to convert Standard_Input to a stream (or use the
> Interfaces.C.Streams <<check package name>> directly)
> and do 'Reads or 'Inputs on the stream
>
> ...
> type My_16_Bits is mod 2**16;
>
>
> My_16 : My_16_Bits;
> ...
>
> In_Stream := Stream (TIO.Standard_Input);
>
> ...
>
> My_Value := My_16_Bits'Read (In_Stream);
>
> ...
Hmmm, ok....this looks more promising. I'll try it. Thanks ;-)
Paula
next prev parent reply other threads:[~2002-10-16 11:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-10-15 16:50 New to Ada..need some help regarding Binary Conversion?? Paula
2002-10-15 17:23 ` Colin Paul Gloster
2002-10-16 11:06 ` Paula
2002-10-16 12:27 ` Marin David Condic
2002-10-15 17:48 ` sk
2002-10-16 11:09 ` Paula [this message]
2002-10-15 18:36 ` Jeffrey Carter
2002-10-15 18:53 ` Larry Hazel
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox