Re: find specify string in text file

Posted by Nancy on January 14, 2005

In Reply to: find specify string in text file posted by vahid bahremand on January 06, 2005

: I want to prepare a program that it can be find a specify string in the text file.
: please lead me.

Read in the textfile into a string variable S.
Use the Delphi Pos() function to check if the specified string is in S, and if yes, where it starts.

var
  P: integer;
  SpecString: string;
begin
  SpecString := 'your textstring';
  P := Pos(SpecString, S);
  if P = 0 then
    ShowMessage(SpecString + ' not found)
  else
    ShowMessage('Your string starts at position ' + IntToStr(P);
end;

Delphi Forum and Tutorials -- by DelphiLand