Documentation
Back to website >

Delete (Pascalscript)

Description 

The Delete procedure removes a substring from a string.

Syntax

procedure Delete(var S: string; Index, Count:Integer);

Arguments

Delete, starting with the position index within the string S Count character from the string S. S is a string variable. Index and count are integer expressions.

If the value of Index is greater than the length of S, no characters are deleted. If more characters are specified with Count than are present in the string starting at position index in S text, the rest of the string is deleted.

Example

var
  S1: String;
begin
  S1:='Today we are testing copying';
  Delete(S1,10,3);
  ShowMessage(S1);
end;

Rules to understand the script can be found here.

The text 'Today we are testing copying' is assigned to the string variable S1. Then exactly 3 characters are removed from position 10 in the original text using the Delete procedure.

ShowMessage shows: Today we  tesing copying

Note that only 3 characters have been deleted, so there are two spaces after 'we'.