Что нужно поменять в коде чтобы считывало в файле количество словосочетаний while нашло

var i,n,count : Integer;
s,g:string;

 
procedure findFiles(path, name : String);
begin
  try
    var f := System.IO.Directory.GetFiles(path, name);
    if f.Count > 0 then
      begin
        count += 1;
        f[0].Println;
        WriteLn('~'*100);
        ReadAllText(f[0]).Println;
        WriteLn('='*100);
      end;
    foreach var sub in System.IO.Directory.GetDirectories(path) do
      findFiles(sub, name);
  except
  end;
end;
 
procedure Working(myDrive, name : String);
begin
  count := 0;
  var ioDrive := System.IO.DriveInfo.GetDrives;
  var Drives := ioDrive.Where(Drive->Drive.Name=myDrive);
  if Drives.Count = 0 then
    begin
      WriteLn('Такого диска нет!');
      Exit;
    end;
  var Drive := Drives.First;
  if Not Drive.IsReady then
    begin
      WriteLn('Диск не готов!');
      Exit;
    end;
  findFiles(drive.RootDirectory.Name, name);
  WriteLn(count=0?'Файлы не найдены!':'Найдено файлов ' + count + '.');
end;
 
begin
  var myDrive := (ReadLnChar('Буква диска:') + ':\').ToUpper;
  writeln('введите название файла');
  var name := ReadLnString(g);
  var EXE := (New System.IO.FileInfo(System.Environment.GetCommandLineArgs[0])).Name;
  var outName := (New System.IO.FileInfo(EXE)).Name.Remove(EXE.Length-3)+'txt';
  Rewrite(output, outName);
  Working(myDrive, name);
  Close(output);
  Working(myDrive, name);
  if System.IO.File.Exists(outName) then ReadAllText(outName);
begin
  assign(input,'lab8.txt');
  reset(input);
begin
  Readln(input,s);
  n:=0;
  for i:=1 to Length(s) do
  if (s[i]='w') and (s[i+1]='h') and (s[i+2]='i') and (s[i+3]='l') and (s[i+4]='e') then
  n:=n+1;
  Write('Количество "while": ', n);
end;
end;
end.

Ответы (0 шт):