+ Reply to Thread
Results 1 to 4 of 4

Thread: Delete(Str: String; Start, Length: Integer)

  1. #1
    Newbie volshba is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    2

    Delete(Str: String; Start, Length: Integer)

    Hello.
    can u help me.
    I have a code:
    Code:
    procedure Tpa.Button2Click(Sender: TObject);
    var
      Temp: TStringList;
      Index: Integer;
       s: Integer;
    begin
         Temp:= TStringList.Create();
      try
        for Index:= 0 to FList.Count - 1 do
    if  ('apple', FList[Index]) <> 0) and (Temp.IndexOf(FList[Index]) = -1)
    then Temp.Add(FList[Index]);
        try
          begin
    Temp.SaveToFile('fruits.txt');                      
       end;
        except
          ShowMessage('error!');
        end;
      finally
        Temp.Free();
      end;
         end;
    and i need use in this button functions "Delete(Str: String; Start, Length: Integer)".
    I need to remove all 'garbage' after this word.
    How do I do this?
    example:
    'apple ererewerwer'
    result:
    only 'apple'

  2. #2
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,698
    Blog Entries
    57

    Re: Delete(Str: String; Start, Length: Integer)

    How are you defining the end of a word? For example, if you have 'apple ererewerwer' in string Data, then I could do:
    Code:
    Data := copy(Data,1,pos(' ',Data)-1);
    to remove all characters starting at the space.
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  3. #3
    Newbie volshba is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    2

    Re: Delete(Str: String; Start, Length: Integer)

    ok. but if i have 'applesdfsdfsdf' without the space?

  4. #4
    Super Moderator WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther has much to be proud of WingedPanther's Avatar
    Join Date
    Jul 2006
    Age
    36
    Posts
    11,698
    Blog Entries
    57

    Re: Delete(Str: String; Start, Length: Integer)

    How are you defining "garbage"? For example, your case could return either 'apple' or 'apples' depending on whether the s is considered garbage or not.
    CodeCall Blog | CodeCall Wiki | Shareware
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 1
    Last Post: 02-20-2009, 11:53 AM
  2. C++: Just some stuff....
    By void_3e01 in forum Classes and Code Snippets
    Replies: 17
    Last Post: 10-14-2008, 11:54 AM
  3. OOP DB Access Wrapper
    By digioz in forum C# Programming
    Replies: 6
    Last Post: 09-07-2008, 12:58 PM
  4. SecurityAudit
    By vinay in forum Visual Basic Programming
    Replies: 27
    Last Post: 01-07-2008, 12:14 PM
  5. Help with SendMessage API
    By MrNobody in forum Visual Basic Programming
    Replies: 8
    Last Post: 11-22-2006, 12:01 PM

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts