[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] Reference for unit 'System' (#rtl)

Delete

Delete elements (characters) from a string or dynamic array.

Declaration

Source position: system.fpd line 45

procedure Delete(

  var S: string;

  const Index: Integer;

  const Count: Integer

);

procedure Delete(

  var A: DynArrayType;

  const Index: Integer;

  const Count: Integer

);

Description

Delete removes Count characters from string S, starting at position Index. Index is 1-based. All characters after the deleted characters are shifted Count positions to the left, and the length of the string is adjusted.

For dynamic arrays, Delete removes Count elements from the array A, starting at position Index. Index is 0-based. All elements after the deleted elements are shifted Count positions to the left, and the length of the array is adjusted.

If the sum of Index and Count exceeds the length of the string or array, Delete removes the end of the string or array, starting at Index.

If Index is less than 1 or greater than the length of the string or array, or if Count is negative or zero, Delete does nothing.

See also

Copy

  

Copy part of a string.

Pos

  

Search for substring in a string.

Insert

  

Insert one string or dynamic array in another.

Example

Program Example15;

{ Program to demonstrate the Delete function. }

Var
  S : String;

begin
  S:='This is not easy !';
  Delete (S,9,4); { S:='This is easy !' }
end.

Documentation generated on: Jun 23 2021