[ Back to the overview Matrix ]

Test case : Type "file" using Ada

Lines used: 24
with Ada.Text_Io; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Sequential_Io;

procedure Files is
   package Char_Io is new Ada.Sequential_Io(Character);
 
   procedure Process(The_File : Char_IO.File_Type) is 
      The_Char : Character;
   begin
      while not Char_IO.End_Of_File(The_File) loop
         Char_Io.Read(File => The_File, Item => The_Char);
         Put(The_Char);
      end loop;
   end Process;
   A_File : Char_IO.File_Type;
begin
   if Argument_Count > 0 then
      Char_Io.Open(File => A_File,
         Mode => Char_Io.In_File,
         Name => Argument(1));
   else
      return;
   end if;
   Process(A_File);
end Files;
Contributed by James S. Rogers, jimmaureenrogers at worldnet.att.net