From RAD Studio API Documentation
Jump to: navigation, search


procedure Delete(var S: <string or dynamic array>; Index: Integer; Count: Integer);


Type Visibility Source Unit Parent
procedure public System.pas System System


Removes a substring from a string or elements range from a dynamic array.

S is a string-type or dynamic array-type variable. Index and Count are integer-type expressions.

Delete has a slightly different behavior depending on S type.


Delete removes a substring of Count characters from a string, starting at S[Index].

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

If Count specifies more characters than the remaining in the string (counting from Index), Delete removes the rest of the string. If the value of Count is equal to or less than 0, then no characters are deleted.

Note: On strings, Delete uses one-based indexing even when zero-based strings are enabled.

Dynamic array-type

Delete removes an element range of Count elements from the array, counting from S[Index].

If Index is equal to or larger than the array's length or less than 0, no elements are deleted.

If Count specifies more elements than the remaining (counting from Index), Delete removes the rest of the array. No elements are deleted if Count is less than or equal to 0.

Dynamic Array Example

  A: array of integer;
  Delete(A,1,2); //A will become [1,4]

See Also

Code Examples