with Ada.Text_IO;
with Ada.Text_IO.Unbounded_IO;
with Ada.Strings.Unbounded;      use Ada.Strings.Unbounded;
with Ada.Containers.Vectors;     use Ada.Containers;
 
procedure Quotes is
   package IO renames Ada.Text_IO;
   package SUIO renames Ada.Text_IO.Unbounded_IO;
   subtype Foo_Range is Natural range 42 .. 52;
   subtype Bar_Range is Integer range -100 .. 100;
   package Quote_Container is new Vectors (Natural, Unbounded_String);
   package Foo_Container is new Vectors (Foo_Range, Unbounded_String);
   package Bar_Container is new Vectors (Bar_Range, Unbounded_String);
   Quotes    : Quote_Container.Vector;
   Foo       : Foo_Container.Vector;
   Bar       : Bar_Container.Vector;
   Input     : IO.File_Type;
   Line      : Unbounded_String;
begin
   IO.Open (File => Input,
            Mode => IO.In_File,
            Name => "quotes.txt");
   while not IO.End_Of_File (File => Input) loop
      Line := SUIO.Get_Line (File => Input);
      Quotes.Append (New_Item => Line);
      Foo.Append (New_Item => Line);
      Bar.Append (New_Item => Line);
   end loop;
   IO.Close (Input);
 
   IO.Put_Line (Item => Quotes.First_Index'Img);
   for i in Quotes.First_Index .. Quotes.Last_Index loop
      IO.Put (Item => i'Img & " ");
      SUIO.Put (Item => Quotes.Element (Index => i));
      IO.New_Line;
   end loop;
   IO.New_Line;
 
   IO.Put_Line (Item => Foo.First_Index'Img);
   for i in Foo.First_Index .. Foo.Last_Index loop
      IO.Put (Item => i'Img & " ");
      SUIO.Put (Item => Foo.Element (Index => i));
      IO.New_Line;
   end loop;
   IO.New_Line;
 
   IO.Put_Line (Item => Bar.First_Index'Img);
   for i in Bar.First_Index .. Bar.Last_Index loop
      IO.Put (Item => i'Img & " ");
      SUIO.Put (Item => Bar.Element (Index => i));
      IO.New_Line;
   end loop;
end Quotes;

Go back


Navigation