?
Solved

Delete string from text file

Posted on 2002-04-29
1
Medium Priority
?
135 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
inthe earned 200 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month10 days, 19 hours left to enroll

770 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