Solved

Delete string from text file

Posted on 2002-04-29
1
130 Views
Last Modified: 2012-05-04
how do i make my programme delete the string 'File was CFFed' that was found in 'C:\File data.txt'. the command will run when i click on a button.
0
Comment
Question by:tyfing
1 Comment
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 6977276
hi,
heres one way:

procedure TForm1.Button1Click(Sender: TObject);
var
 sl : tstringlist;
  i : integer;
  s1 : string;
  SearchStr : string;
  place : integer;
begin
sl := tstringlist.create;
SL.LoadFromFile('C:\Winzip.log');
  SearchStr := 'File was CFFed';
  for i := 0 to SL.Count -1 do begin
    s1 := SL.Strings[i];
    Repeat
      Place := pos(SearchStr, s1);
      if place > 0 then begin
        Delete(s1, Place, Length(SearchStr));
        SL.Strings[i] := s1;
      end;
    until place = 0;
  end;
  sl.SaveToFile('C:\Winzip.log');
  sl.free;
end;
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now