From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b5982b7c8eb7a4fc X-Google-Attributes: gid103376,public From: "Norman H. Cohen" Subject: Re: Simple Stream_IO question Date: 1996/10/22 Message-ID: <326D2E76.63BE@watson.ibm.com>#1/1 X-Deja-AN: 191312826 references: content-type: text/plain; charset=us-ascii organization: IBM Thomas J. Watson Research Center mime-version: 1.0 reply-to: ncohen@watson.ibm.com newsgroups: comp.lang.ada x-mailer: Mozilla 3.0 (Win95; I) Date: 1996-10-22T00:00:00+00:00 List-Id: 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