comparing string with strings

Posted by john on April 11, 2006

I use the code below to get the last line from a text file.

My q? How can i compare this line with the other lines in the file? if the line finds a match then stop(do nothing), if it doesn't then post to Memo1.Text

function ReadFile(FileName:string):string;
  var
  F:TextFile;
  S:string;
begin
  if FileExists(FileName) then begin
    AssignFile(F, FileName);
    Reset(F);
    while not EOF(F) do begin
      ReadLn(F, S);
      Result:=S;
    end;
    CloseFile(F);
  end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  Memo1.Text := ReadFile( 'C:/File.txt');
end;

Related Articles and Replies