                                (* Chapter 8 - Program 4 *)
program Find_All_Lower_Case_Characters;

const String_Size = 30;

type Low_Set = set of 'a'..'z';

var Data_Set    : Low_Set;
    Storage     : string[String_Size];
    Index       : 1..String_Size;
    Print_Group : string[26];

begin  (* main program *)
   Data_Set := [];
   Print_Group := '';
   Storage := 'This is a set test.';

   for Index := 1 to Length(Storage) do begin
      if Storage[Index] in ['a'..'z'] then begin
         if Storage[Index] in Data_Set then
            Writeln(Index:4,'   ',Storage[Index],
                         ' is already in the set')
         else begin
            Data_Set := Data_Set + [Storage[Index]];
            Print_Group := Print_Group + Storage[Index];
            Writeln(Index:4,'   ',Storage[Index],
                         ' added to group, complete group = ',
                         Print_Group);
         end;
      end
      else
         Writeln(Index:4,'   ',Storage[Index],
                       ' is not a lower case letter');
   end;
end.  (* of main program *)




{ Result of execution

   1   T is not a lower case letter
   2   h added to group, complete group = h
   3   i added to group, complete group = hi
   4   s added to group, complete group = his
   5     is not a lower case letter
   6   i is already in the set
   7   s is already in the set
   8     is not a lower case letter
   9   a added to group, complete group = hisa
  10     is not a lower case letter
  11   s is already in the set
  12   e added to group, complete group = hisae
  13   t added to group, complete group = hiseat
  14     is not a lower case letter
  15   t is already in the set
  16   e is already in the set
  17   s is already in the set
  18   t is already in the set
  19   . is not a lower case letter

}
