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;
   package Quote_Container is new Vectors (Natural, Unbounded_String);
   use Quote_Container;
   Quotes    : Vector;
   Input     : IO.File_Type;
   Needle    : Unbounded_String;
begin
   IO.Open (File => Input,
            Mode => IO.In_File,
            Name => "quotes.txt");
   while not IO.End_Of_File (File => Input) loop
      Quotes.Append (New_Item => SUIO.Get_Line (File => Input));
   end loop;
   IO.Close (Input);
 
   Needle := To_Unbounded_String ("FooBar");
   if Quotes.Contains (Item => Needle) then
      IO.Put_Line (Item => "Found!");   
   else
      IO.Put_Line (Item => "Not found!");   
   end if;
 
   Needle := To_Unbounded_String 
     ("Most days I wake up thinking I'm the luckiest bastard alive.");
   if Quotes.Contains (Item => Needle) then
      IO.Put_Line (Item => "Found!");   
   else
      IO.Put_Line (Item => "Not found!");   
   end if;
end Quotes;

Go back


Navigation