home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ipo-101.zip / Samples.zip / VOWELS.PAS < prev   
Pascal/Delphi Source File  |  1998-11-15  |  1KB  |  40 lines

  1. (*
  2. This program is used to count the number of vowels and the total number of 
  3. characters in the input file.
  4. NOTE: This program makes use of two features of Irie Pascal
  5. 1) If the user does not specify a command-line parameter to match the
  6. program argument 'f' then 'f' is automatically assigned an empty string
  7. as it's filename.
  8. 2) If a file variable with an empty string as it's filename is reset then
  9. the standard input file is associated with the file variable.
  10.  
  11. The net effect of these two features is that if you run this program and
  12. don't supply a program argument like "ivm vowels" then the program reads
  13. from the standad input file. If you run this program with a program argument
  14. like "ivm vowels filename" then the program will open "filename" and read
  15. from it.
  16. *)
  17. program vowels(f, output);
  18. var
  19.    f : file of char;
  20.    tot, vow : integer;
  21.    c : char;
  22. begin
  23.    reset(f);
  24.    tot := 0;
  25.    vow := 0;
  26.    while not eof(f) do
  27.       begin
  28.          read(f, c);
  29.          case c of
  30.             'a', 'e', 'i', 'o', 'u',
  31.             'A', 'E', 'I', 'O', 'U'
  32.                : vow := vow + 1;
  33.             otherwise
  34.          end;
  35.          tot := tot + 1;
  36.       end;
  37.    writeln('Total characters read = ', tot);
  38.    writeln('Vowels read = ', vow)
  39. end.
  40.