Re: A nearly finished Frequency Program

Posted by webmaster Guido on May 24, 2003

In Reply to: A nearly finished Frequency Program posted by James on May 22, 2003

Well, as a rule we only discuss GUI programs, not console applications. But as the solution to this one is fairly short, I gave it a try ;-)

procedure Populate(var Frequencies: ArrayType );
var
  F: textfile;
  CH: char;
begin
  AssignFile(F, FileName);
  Reset(F);
  while not Eof(F) do begin
    Read(F, Ch);
    // If necessary, convert to upperCase
    if Ch in ['a'..'z'] then
      Ch := Chr(Ord(Ch) - 32);
    if Ch in ['A'..'Z'] then
      inc(Frequencies[Ch]);
  end;
  CloseFile(F);
end;

[ Delphi Forum ]
Compiling Console Applications
Learn Pascal with simple Delphi Console Applications