Closed Thread
Results 1 to 4 of 4

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

  1. #1
    volshba is offline Newbie
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

  4. #3
    volshba is offline Newbie
    Join Date
    Jun 2009
    Posts
    2
    Rep Power
    0

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

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

  5. #4
    Join Date
    Jul 2006
    Posts
    16,486
    Blog Entries
    75
    Rep Power
    143

    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.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using malloc() and realloc() for a variable-length string
    By DarkLordofthePenguins in forum C and C++
    Replies: 6
    Last Post: 03-17-2011, 10:04 PM
  2. string to integer problem
    By Masonic in forum Pascal and Delphi
    Replies: 2
    Last Post: 11-18-2010, 10:10 AM
  3. convert integer into string...
    By veda87 in forum C and C++
    Replies: 4
    Last Post: 09-07-2009, 12:49 PM
  4. Limit String entry length
    By Xdawn90 in forum Java Help
    Replies: 5
    Last Post: 07-10-2009, 10:13 AM
  5. String of Hex to Integer
    By $AP in forum C and C++
    Replies: 13
    Last Post: 02-13-2009, 05:40 AM

Tags for this Thread

Bookmarks

Posting Permissions

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