* How does one use Ada.Streams.Stream_IO?
@ 1997-07-30 0:00 Matthew Kennedy
1997-07-30 0:00 ` Robert Dewar
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Matthew Kennedy @ 1997-07-30 0:00 UTC (permalink / raw)
Hello all,
OK, the solution to my multiple-record-types-from-the-one-file problem
is Ada.Streams.Stream_IO. However, I don't know how to instantiate(?) it
properly.
Does anyone have a simple example of how to do this?
Sources of examples I've already tried:
* examples the come with GNAT for DOS
* cs1code
* cs2code
* lovelace tutorial
* ada tutor
* books
But these have no mention of stream operations.
Thanks,
Matt
--
Matthew Kennedy
Student of Electronics Engineering
University of Southern Queensland, Australia
"When will you realise your already there?"
- Marilyn Manson
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How does one use Ada.Streams.Stream_IO?
1997-07-30 0:00 How does one use Ada.Streams.Stream_IO? Matthew Kennedy
1997-07-30 0:00 ` Robert Dewar
@ 1997-07-30 0:00 ` Jon S Anthony
1997-08-01 0:00 ` Pascal Obry
2 siblings, 0 replies; 4+ messages in thread
From: Jon S Anthony @ 1997-07-30 0:00 UTC (permalink / raw)
In article <33DF3D90.155D@mail.connect.usq.edu.au> Matthew Kennedy <q9522772@mail.connect.usq.edu.au> writes:
> OK, the solution to my multiple-record-types-from-the-one-file problem
> is Ada.Streams.Stream_IO. However, I don't know how to instantiate(?) it
> properly.
>
> Does anyone have a simple example of how to do this?
>
> Sources of examples I've already tried:
>
<...>
>
> But these have no mention of stream operations.
Well, Barnes covers this in reasonable detail in 20.6 of _Programming
in Ada95"_. Cohen covers this too - somewhere toward the end of the
book (I have Barnes handy, but not Cohen...)
/Jon
--
Jon Anthony
OMI, Belmont, MA 02178
617.484.3383
"Nightmares - Ha! The way my life's been going lately,
Who'd notice?" -- Londo Mollari
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How does one use Ada.Streams.Stream_IO?
1997-07-30 0:00 How does one use Ada.Streams.Stream_IO? Matthew Kennedy
@ 1997-07-30 0:00 ` Robert Dewar
1997-07-30 0:00 ` Jon S Anthony
1997-08-01 0:00 ` Pascal Obry
2 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1997-07-30 0:00 UTC (permalink / raw)
Matt asks
<<OK, the solution to my multiple-record-types-from-the-one-file problem
is Ada.Streams.Stream_IO. However, I don't know how to instantiate(?) it
properly.
>>
Well you won't get very far trying to instantiate Stream_IO, since it is
not a generic package! Just with it, and then use the subprograms much
as you would in the case of Text_IO, except that the actual stream
operations are typically done using the standard stream attributes,
e.g. x'Output (stream, item) to write and X'Input (Stream) to read.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How does one use Ada.Streams.Stream_IO?
1997-07-30 0:00 How does one use Ada.Streams.Stream_IO? Matthew Kennedy
1997-07-30 0:00 ` Robert Dewar
1997-07-30 0:00 ` Jon S Anthony
@ 1997-08-01 0:00 ` Pascal Obry
2 siblings, 0 replies; 4+ messages in thread
From: Pascal Obry @ 1997-08-01 0:00 UTC (permalink / raw)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1710 bytes --]
Here is a small example :
with Ada.Streams.Stream_IO;
procedure Streams is
use Ada;
Max_Datas : constant := 100_000;
type Datas is array (1 .. Max_Datas) of Integer;
D : Datas := (1 | 2 | 4 | 6 | 8 => 50, others => 1);
procedure Write_Stream is
package Data_IO renames Ada.Streams.Stream_IO;
F : Data_IO.File_Type;
begin
Data_IO.Create (F, Name => "tmp_s.data", Mode => Data_IO.Out_File);
for I in D'Range loop
Integer'Write (Data_IO.Stream (F), D(I));
end loop;
Data_IO.Close (F);
end Write_Stream;
procedure Write_Array_Stream is
package Data_IO renames Ada.Streams.Stream_IO;
F : Data_IO.File_Type;
begin
Data_IO.Create (F, Name => "tmp_a.data", Mode => Data_IO.Out_File);
Datas'Write (Data_IO.Stream (F), D);
Data_IO.Close (F);
end Write_Array_Stream;
begin
null;
end Streams;
Hope this helps,
Pascal.
--
--|------------------------------------------------------------
--| Pascal Obry Team-Ada Member |
--| |
--| EDF-DER-IPN-SID- Ing�nierie des Syst�mes d'Informations |
--| |
--| Bureau G1-010 e-mail: pascal.obry@der.edfgdf.fr |
--| 1 Av G�n�ral de Gaulle voice : +33-1-47.65.50.91 |
--| 92141 Clamart CEDEX fax : +33-1-47.65.50.07 |
--| FRANCE |
--|------------------------------------------------------------
--|
--| http://ourworld.compuserve.com/homepages/pascal_obry
--|
--| "The best way to travel is by means of imagination"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1997-08-01 0:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-30 0:00 How does one use Ada.Streams.Stream_IO? Matthew Kennedy
1997-07-30 0:00 ` Robert Dewar
1997-07-30 0:00 ` Jon S Anthony
1997-08-01 0:00 ` Pascal Obry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox