From: "Norman H. Cohen" <ncohen@watson.ibm.com>
Subject: Re: Simple Stream_IO question
Date: 1996/10/22
Date: 1996-10-22T00:00:00+00:00 [thread overview]
Message-ID: <326D2E76.63BE@watson.ibm.com> (raw)
In-Reply-To: Pine.LNX.3.91.961021132826.300A-100000@e229b-1.ensu.ucalgary.ca
John Raquet wrote:
> If someone could show me what I'm doing wrong in the following code
> sample I'd appreciate it:
>
> -----------------
> with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
>
> procedure Foo is
>
> F : Float;
> I : Integer;
>
> File : File_Type;
>
> begin
>
> Open(File, In_File, "foo.adb");
>
> Float'Read(File, F);
> Integer'Read(File, I);
>
> Close(File);
>
> end Foo;
The first parameter in a call on a 'Read attribute must be an access
value of a type pointing to Root_Stream'Class. Package
Ada.Streams.Stream_IO provides such a type, named Stream_Access. The
package also provides its own type File_Type (the type of File in the
example above) and a function Stream that takes a File_Type parameter
and returns a Stream_Access parameter pointing to a stream that
corresponds to the given file. Thus you should write:
Float'Read ( Stream(File), F );
Integer'Read ( Stream(File), I );
--
Norman H. Cohen
mailto:ncohen@watson.ibm.com
http://www.research.ibm.com/people/n/ncohen
prev parent reply other threads:[~1996-10-22 0:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-10-21 0:00 Simple Stream_IO question John Raquet
1996-10-21 0:00 ` Robert Dewar
1996-10-22 0:00 ` John English
1996-10-22 0:00 ` Norman H. Cohen [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox