home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / PASSRC.ZIP / FINDCHRS.PAS < prev    next >
Pascal/Delphi Source File  |  1991-02-04  |  2KB  |  63 lines

  1.                                 (* Chapter 8 - Program 4 *)
  2. program Find_All_Lower_Case_Characters;
  3.  
  4. const String_Size = 30;
  5.  
  6. type Low_Set = set of 'a'..'z';
  7.  
  8. var Data_Set    : Low_Set;
  9.     Storage     : string[String_Size];
  10.     Index       : 1..String_Size;
  11.     Print_Group : string[26];
  12.  
  13. begin  (* main program *)
  14.    Data_Set := [];
  15.    Print_Group := '';
  16.    Storage := 'This is a set test.';
  17.  
  18.    for Index := 1 to Length(Storage) do begin
  19.       if Storage[Index] in ['a'..'z'] then begin
  20.          if Storage[Index] in Data_Set then
  21.             Writeln(Index:4,'   ',Storage[Index],
  22.                          ' is already in the set')
  23.          else begin
  24.             Data_Set := Data_Set + [Storage[Index]];
  25.             Print_Group := Print_Group + Storage[Index];
  26.             Writeln(Index:4,'   ',Storage[Index],
  27.                          ' added to group, complete group = ',
  28.                          Print_Group);
  29.          end;
  30.       end
  31.       else
  32.          Writeln(Index:4,'   ',Storage[Index],
  33.                        ' is not a lower case letter');
  34.    end;
  35. end.  (* of main program *)
  36.  
  37.  
  38.  
  39.  
  40. { Result of execution
  41.  
  42.    1   T is not a lower case letter
  43.    2   h added to group, complete group = h
  44.    3   i added to group, complete group = hi
  45.    4   s added to group, complete group = his
  46.    5     is not a lower case letter
  47.    6   i is already in the set
  48.    7   s is already in the set
  49.    8     is not a lower case letter
  50.    9   a added to group, complete group = hisa
  51.   10     is not a lower case letter
  52.   11   s is already in the set
  53.   12   e added to group, complete group = hisae
  54.   13   t added to group, complete group = hiseat
  55.   14     is not a lower case letter
  56.   15   t is already in the set
  57.   16   e is already in the set
  58.   17   s is already in the set
  59.   18   t is already in the set
  60.   19   . is not a lower case letter
  61.  
  62. }
  63.