With IO, Sect; -- The Package in which the type sector is declared. Package Randio Is -- Copyright 1984 RR Software, Inc., P.O. Box 1512, Madison WI 53701 -- Permission is hereby given to distribute Object Code produced from -- these libraries. All Other rights reserved. -- -- JANUS/Ada Random I/O Package. -- Modeled on Ada Direct_IO. -- -- How to use this Package -- -- This Package is designed as an Ada Generic Package. However, since -- Generics are not yet available in JANUS/Ada, the method for using -- this package is a bit awkward. The Type Sector must imported from -- some other Package, by changing the With Clause, and the Subtype -- declaration. Note that the name 'Sector' is used in only one place, -- and thus can easily be changed to any other type. Then both the -- Specification and Body of RandIO must be recompiled. -- -- The following classes of types must not be used as the type Sector -- (cannot be output or input): -- Limited Private Types -- Access Types -- Composite Types containing either of the above. -- Any other type may be output or input. -- -- Io.IOResult can be tested for errors in this version. -- -- Records are numbered from 1, as per the 1983 Ada Standard. Subtype Element_Type Is Sect.Sector; --Replace Sect.Sector with your type Type File_Type Is Limited Private; -- Many routines below have two forms, one which is compatible with -- current JANUS/Ada I/O, and the second which is compatible with the -- 1983 Ada standard. We recommend using the Ada forms wherever -- possible, as the JANUS/Ada forms will be phased out. Type File_Mode Is (IN_File,INOUT_File,OUT_File); Type Count Is New Natural; Subtype Positive_Count Is Count Range 1 .. Count'Last; Procedure Open (Fyle : In Out File_Type; Name : In String; Mode : In IO.File_Mode); -- Opens a file for I/O. JANUS/Ada version. Procedure Open (Fyle : In Out File_Type; Mode : In File_Mode; Name : In String); -- Opens a file for I/O. Ada 83 version. Procedure Create (Fyle : In Out File_Type; Name : In String; Mode : In IO.File_Mode); -- Creates a new file for I/O. JANUS/Ada version. Procedure Create (Fyle : In Out File_Type; Mode : In File_Mode; Name : In String); -- Creates a new file for I/O. Ada 83 version. Procedure Close (Fyle : In Out File_Type); -- Closes a file. -- Procedure Delete (Fyle : In Out File_Type); -- Deletes a file. Ada 83 version. ** Not implemented ** -- Procedure Delete (Name : In String); -- Deletes a file. Janus/Ada version. Use the one in I/O. -- Procedure Reset (File : In Out File_Type; Mode : In File_Mode); -- Resets a file. Ada 83 only. ** Not implemented ** Function Mode (Fyle : In File_Type) Return Io.File_Mode; -- Returns the current mode of Fyle. Janus/Ada version. -- Function Mode (Fyle : In File_Type) Return File_Mode; -- Returns the current mode of Fyle. Ada 83 version. -- ** Not implemented because overloading on return types -- is disallowed in Janus/Ada. Function Name (Fyle : In File_Type) Return String; -- Returns the name of Fyle. Function Is_Open (Fyle : In File_Type) Return Boolean; -- Return True if the file is Open. Procedure Read (Fyle : In File_Type; Item : Out Element_Type; Rec : In positive_count); -- Read the record at record number positive count. IOresult is -- set to 255 if it does not exist. Procedure Read (Fyle : In File_Type; Item : Out Element_Type); -- Read the record following the last one read or written. -- IOresult is set to 255 if it does not exist. Procedure Write (Fyle : In File_Type; Item : In Element_Type; Rec : In positive_count); -- Write the record at record number positive count. IOresult is -- set to 255 if an error occurs. (The disk is probably full). Procedure Write (Fyle : In File_Type; Item : In Element_Type); -- Write the record following the last one read or written. -- IOresult is set the same as above. Procedure Set_Index (Fyle : In File_Type; Rec : In Positive_Count); -- Set the next record to be read or written, if a number is not -- specified. Function Index (Fyle : In File_Type) Return Positive_Count; -- Returns the number of the next record to be read or written. Function Size (Fyle : In File_Type) Return Count; -- Returns the current size of the file, in records. Function End_of_File (Fyle : In File_Type) Return Boolean; -- Returns True if the current index points past the end of the file. Private Type File_Block; Type File_Type Is Access File_Block; Type File_Block Is Record Fyle : File; Index : Positive_Count; End Record; End RandIO;  the next record to be read or written. Function Size (Fyle : In File_Type) Return Count; -- Returns the current size _Type; Item : In Element_Type); -- Write the record following the last one read or written. -- IOresult is set the same as a