-- This program illustrates the use of both command line arguments (for the -- eternally curious) and of I/O from named files. with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure Text is Input_File, Output_File : File_Type; Number : Float; begin -- Example of opening, closing, and doing I/O with named files. -- Open (File => Input_File, Mode => In_File, Name => "Data_File"); Create (File => Output_File, Mode => Out_File, Name => "Result_File"); loop exit when End_Of_File (Input_File); Get (File => Input_File, Item => Number); Put (File => Output_File, Item => Number); New_Line (File => Output_File); end loop; Close (File => Input_File); Close (File => Output_File); -- Example of getting file names from the command line and then -- appending the string "APPENDED" to each one. -- for I in 1..Argument_Count loop Put (Item => "Appending to file '"); Put (Item => Argument(I)); Put_Line (Item => "'."); -- Open will raise an ADA.IO_EXCEPTIONS.NAME_ERROR expection -- if the file named by Argument(I) does not already exist. -- Open (File => Output_File, Mode => Append_File, Name => Argument(I)); Put_Line (File => Output_File, Item => "APPENDED"); Close (File => Output_File); end loop; Put (Item => "This program was invoked by using the command '"); Put (Item => Command_Name); Put_Line (Item => "'."); end Text;