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,94d3b604ce565768,start X-Google-Attributes: gid103376,public From: Matthew Kennedy Subject: How do I use Direct_IO many times on the same opened file? Date: 1997/07/26 Message-ID: <33D8D284.16EB@mail.connect.usq.edu.au>#1/1 X-Deja-AN: 258908853 Organization: University of Southern Queensland Reply-To: q9522772@mail.connect.usq.edu.au Newsgroups: comp.lang.ada Date: 1997-07-26T00:00:00+00:00 List-Id: I need to read in a BMP file for image analysis. First I read the header into a packed record, then I need to read in the palette based on the information in the header (this goes into an array) and then, finally, I read in the raw data. My approach was to instantiate a BMP_Header_IO, a BMP_Palette_IO and a BMP_Data_IO from the Direct_IO package. This is the bare essentials of my original code... (errors follow after) with Direct_IO, Interfaces, Interfaces.C, Text_IO, Mode_13h; use Interfaces, Interfaces.C, Mode_13h; procedure BMP_Info is type Bmp_Header is record Identification : Char_Array(1..2); -- etc ... Colours_Important : Unsigned_32; end record; type Bmp_Palette_Entry is record Blue, Red, Green, Reserved : Unsigned_8; end record; type Bmp_Palette is array(0..Unsigned_8'Last) of Bmp_Palette_Entry; pragma Pack(Bmp_Header); pragma Pack(Bmp_Palette_Entry); pragma Pack(Bmp_Palette); procedure Put(Item : in Bmp_Header) is use Text_IO; B : Char := Item.Identification(1); M : Char := Item.Identification(2); begin Put_Line("Identification : " & Char'Image(B) & "," & Char'Image(M)); -- etc ... end Put; package Bmp_Header_IO is new Direct_IO(Bmp_Header); use Bmp_Header_IO; package Bmp_Palette_IO is new Direct_IO(Bmp_Palette); use Bmp_Palette_IO; Header : Bmp_Header; Palette : Bmp_Palette; Bitmap_File : File_Type; Bmp_Not_Supported : exception; begin Open(Bitmap_File, In_File, "C:/TEMP/TEST.BMP"); Read(Bitmap_File, Header); if Header.Bits /= 8 then raise Bmp_Not_Supported; end if; Read(Bitmap_File, Palette); Close(Bitmap_File); Put(Specification.Header); exception when Bmp_Not_Supported => Set_Mode_Revert; Text_IO.Put_Line("This BMP file format is not supported."); end BMP_Info; These are the errors I experienced: cd f:/gnu/ gnatmake bmp_info gcc -c bmp_info.adb bmp_info.adb:62:18: "File_Type" is not visible bmp_info.adb:62:18: multiple use clauses cause hiding bmp_info.adb:62:18: hidden declaration at a-direio.ads:28, instance at line 57 bmp_info.adb:62:18: hidden declaration at a-direio.ads:28, instance at line 54 f:/gnu/bin/gnatmake.exe: "bmp_info.adb" compilation error I sort-of understand why File_Type isn't visible but I would like to hear from you if you can suggest a work-around or a different approach. -- Matthew Kennedy Student of Electronics Engineering University of Southern Queensland, Australia "When will you realise your already there?" - Marilyn Manson