Permalink
Browse files

Small experiment in reading a file and dumping it out, one character …

…at a time :(
  • Loading branch information...
1 parent c4a8de2 commit 06eb9f7b5b686743d9b66499cfdb4dc5aef925ca @rtyler committed Oct 30, 2010
Showing with 29 additions and 0 deletions.
  1. +29 −0 readself.adb
View
@@ -0,0 +1,29 @@
+-- Simple Ada program to read "itself" (the file it's compiled from)
+-- and print it out
+--
+--
+with Ada.Sequential_IO;
+with Ada.Text_IO;
+
+procedure readself is
+ package IO is new Ada.Sequential_IO(Element_Type => Character);
+ SourceFile : IO.File_Type;
+begin
+
+ Ada.Text_IO.New_Line;
+ IO.Open(SourceFile, IO.In_File, "readself.adb");
+
+ declare
+ C : Character;
+ begin
+ while not IO.End_Of_File(SourceFile)
+ loop
+ IO.Read(SourceFile, C);
+ Ada.Text_IO.Put(C);
+ end loop;
+ end;
+
+ IO.Close(SourceFile);
+ Ada.Text_IO.New_Line;
+
+end;

0 comments on commit 06eb9f7

Please sign in to comment.