program Scan_Userdefinable_Letters;

var inp        : text;
    filnam     : string[20];
    ch         : char;
    code       : byte;
    ctl        : array[0..$1F] of integer;
    user       : array[0..$7F] of integer;

begin
  write('Dateiname : ');
  readln(filnam);
  assign(inp,filnam);
  reset(inp);
  fillchar(ctl,64,0);
  fillchar(user,256,0);
  while not eof(inp) do begin
    read(inp,ch);
    code:=ord(ch) and $7F;
    if code<32 then ctl[code]:=succ(ctl[code]);
    if code=17 then begin  (* ^Q *)
      read(inp,ch);
      code:=ord(ch) and $7F;
      user[code]:=succ(user[code]);
      end;
    end;
  writeln(^M^J'Control-Codes :');
  for code:=0 to $1F do if ctl[code]>0
    then writeln('^',chr(code+$40),'   : ',ctl[code]:4,' mal');
  writeln(^M^J'User-Zeichen :');
  for code:=0 to $1F do if user[code]>0
    then writeln('^Q^',chr(code+$40),' : ',user[code]:4,' mal');
  for code:=$20 to $7F do if user[code]>0
    then writeln('^Q ',chr(code),' : ',user[code]:4,' mal');
  writeln;
  end.

