Skip to content

Instantly share code, notes, and snippets.

@sparre
Forked from charlie5/gist:a3855c1ffdcd6cafce1ea87cb671b345
Last active January 19, 2017 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sparre/6225a33762817f7d8249fb07034be418 to your computer and use it in GitHub Desktop.
Save sparre/6225a33762817f7d8249fb07034be418 to your computer and use it in GitHub Desktop.
Reading records with Ada.Direct_IO
with Ada.Direct_IO;
with Ada.Text_IO; -- For demonstration purposes.
procedure Tail is
type Your_Record is String (1 .. 8);
package Record_IO is new Ada.Direct_IO (Element_Type => Your_Record);
Source : Record_IO.File_Type;
Value : Your_Record;
begin
Record_IO.Open (Name => "your_file",
File => Source,
Mode => Record_IO.In_File);
for Index in Record_IO.Size (Source) - 3 .. Record_IO.Size (Source) loop
Direct_IO.Read (File => Source,
From => Index,
Item => Value);
Ada.Text_IO.Put_Line ("Index: " & Index'Image & " Value: """ & Value & """");
end loop;
Record_IO.Close (File => Source);
end Tail;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment