RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Delete Function

Removes a substring from a string.

Pascal
procedure Delete(var S: string; Index: Integer; Count: Integer);
C++
Delete(AnsiString S, int Index, int Count);

In Delphi code, Delete removes a substring of Count characters from string S starting with S[Index]. S is a string-type variable. Index and Count are integer-type expressions.  

If index is larger than the length of the string or less than 1, no characters are deleted. 

If count specifies more characters than remain starting at the index, Delete removes the rest of the string. If count is less than or equal to 0, no characters are deleted.  

Delphi Examples: 

 

{
This example uses the Delete function to edit a string.
}

procedure TForm1.Button1Click(Sender: TObject);
var
  s: string;
begin
  s := 'Honest Abe Lincoln';
  Canvas.TextOut(10, 10, s);
  Delete(s,8,4);
  Canvas.TextOut(10, 40, s);    { 'Honest Lincoln' }
end;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!