Go Back   CodeCall Programming Forum > Software Development > Pascal/Delphi
Register Blogs Search Today's Posts Mark Forums Read

Pascal/Delphi Forum for discussing Borland Delphi and Pascal coding techniques, tips and tricks.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-25-2009, 11:05 AM
Newbie
 
Join Date: Jun 2009
Posts: 2
volshba is an unknown quantity at this point
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'
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-25-2009, 01:36 PM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-25-2009, 02:07 PM
Newbie
 
Join Date: Jun 2009
Posts: 2
volshba is an unknown quantity at this point
Re: Delete(Str: String; Start, Length: Integer)

ok. but if i have 'applesdfsdfsdf' without the space?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-25-2009, 03:13 PM
WingedPanther's Avatar
Super Moderator
 
Join Date: Jul 2006
Age: 36
Posts: 11,435
WingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud ofWingedPanther has much to be proud of
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
String insertion in C as part of a string and pointer tutorial Yuriy M C and C++ 1 02-20-2009 12:53 PM
C++: Just some stuff.... void_3e01 Classes and Code Snippets 17 10-14-2008 12:54 PM
OOP DB Access Wrapper digioz C# Programming 6 09-07-2008 01:58 PM
SecurityAudit vinay Visual Basic Programming 27 01-07-2008 01:14 PM
Help with SendMessage API MrNobody Visual Basic Programming 8 11-22-2006 01:01 PM


All times are GMT -5. The time now is 08:15 AM.


vBulletin v3.8.0 ©2010, Jelsoft Enterprises Ltd.


no new posts

LinkBacks Enabled by vBSEO 3.1.0