Ada Programming/Libraries/Ada.Sequential IO

is a unit of the Predefined Language Environment since Ada 95.

Background
Not all data read or written is in text format. For storage or inter-process communication, it is more space- and processing time-efficient to store data in binary format.

Binary input and output for sequential data (that is, read/written one after another) is managed by the generic Ada package.

The generic package must be instantiated with some, and provides a limited private.

The file mode,  or , is established on open or create.

The package provides the basic input/output (I/O) operations:
 * ,, and
 * ,, and

In addition, the package provides status and information functions:
 * ,, and
 * ,, and
 * ,, and

One important restriction is that every element of a file must be the same element type.

Ada Code Example
For example, suppose that a student has collected information on trees in a 10 meter by 10 meter plot, and wishes a report generated from the data.

The following is a simple program to read the sequential data, previously recorded: Tree_Report Tree_Record Common_Name     String120 Scientific_Name String120 Diameter        Float          00 Tree_IO  AdaSequential_IOTree_Record Tree_File Tree_IOFile_Type Tree_Data Tree_Record Tree_IOOpenFile Tree_File Mode Tree_IOIn_File Name "tree.dat" AdaText_IOSet_ColTo  1 AdaText_IOPut"COMMON NAME" AdaText_IOSet_ColTo 21 AdaText_IOPut"SCIENTIFIC NAME" AdaText_IOSet_ColTo 41 AdaText_IOPut"DBH" AdaText_IONew_Line Process_Tree_Data Tree_IOEnd_Of_FileTree_File Tree_IOReadTree_File Tree_Data AdaText_IOPutTree_DataCommon_Name AdaText_IOPutTree_DataScientific_Name AdaFloat_Text_IOPutTree_DataDiameterFore2Aft2Exp0 AdaText_IONew_Line Process_Tree_Data Tree_IOCloseTree_File Tree_Report

Specification
Element_Type File_Type File_Mode In_File Out_File Append_File Create File   File_Type Mode  File_Mode  Out_File Name  String  "" Form  String  "" Open File    File_Type Mode  File_Mode Name  String Form  String  "" Close File   File_Type Delete File   File_Type Reset File   File_Type Mode   File_Mode Reset File   File_Type Mode  File   File_Type  File_Mode Name  File   File_Type  String Form  File   File_Type  String Is_Open File  File_Type  Boolean Read File   File_Type Item   Element_Type Write File  File_Type Item   Element_Type End_Of_File File  File_Type  Boolean Status_Error   IO_ExceptionsStatus_Error Mode_Error     IO_ExceptionsMode_Error Name_Error     IO_ExceptionsName_Error Use_Error      IO_ExceptionsUse_Error Device_Error   IO_ExceptionsDevice_Error End_Error      IO_ExceptionsEnd_Error Data_Error     IO_ExceptionsData_Error File_Type AdaSequential_IO

Wikibook

 * Ada Programming/Libraries/Ada