Procedure TForm1.Proc_Command (var Textline :string);
var File : Textfile;
index : integer;
Textline : string;
begin
AssignFile(File,'C:\MyLog.log');
Reset(File);
While not Eof do
begin
Readln (File,Textline);
index := pos('commands', Textline);
if index <> 0 then Memo1.lines.append(Textline);
end;
Close(File);
end;
I'll explain the lines each..
AssignFile([var:Textfile],[LocationFile:String]); This assigns the file to a variable (TextFile);
Reset([var:Textfile]); This lets you begin READING the file, u have to use Rewrite to be able to Writeln the file
While not eof do .. this means While NOT EndOfFile Do
Readln([var:Textfile],[TextLine:String]); just a normal Readln, only difference is that the first paramater is used to point out the file. (baaad english )
index := pos(Stringyoulookfor:String,Textline:String); if commands exists, it will store the index where it is in TextlineString.
No occurence returns 0 (courtesy of CTRL-C and svanels )
if index <> 0 then Memo1.lines.append(Textline); if index is not 0 (thus 'commands' exist in the textline) then append the Textline to Memo1.
Close([File:TextFile]); Closes the File.
maybe i have given a little bit too much information but this is my first time too E-mail: Rob@matas.nl (till Jan 10, from then on it's Deathwish@winning.com)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.