Solved

Delete string from text file

Posted on 2002-04-29
1
129 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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 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

11 Experts available now in Live!

Get 1:1 Help Now