From: sk <noname@myob.com>
Subject: Re: New to Ada..need some help regarding Binary Conversion??
Date: Tue, 15 Oct 2002 12:48:25 -0500
Date: 2002-10-15T12:48:25-05:00 [thread overview]
Message-ID: <mailman.1034704382.5852.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: 4ee1d187.0210150850.62ce918a@posting.google.com
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);
...
--
-------------------------------------
-- Merge vertically for real address
-------------------------------------
s n p @ t . o
k i e k c c m
-------------------------------------
next prev parent reply other threads:[~2002-10-15 17:48 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 [this message]
2002-10-16 11:09 ` Paula
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