Documentation
Back to website >

Insert (Pascalscript)

Description

The Insert procedure inserts a substring into a string at a specific position.

Syntax

procedure Insert(Source: string; var S: string; Index: Integer);

Arguments

Insert inserts Source in S at the Index in S position.

Source is a string expression and S is a string variable of any length. The integer-expression index is a character index and specifies the position in S from which the text is to be inserted.

Excample

var
  S1: String;
  S2: String;
begin
  S1:='insert ';
  S2:='Testing today.';
  Insert(S1,S2,12);
  ShowMessage(S2);
end;

Rules to understand the script can be found here.

The text 'insert ' is assigned to the string variable S1 and the string variable S2 'Testing today.'. The Insert procedure inserts the content of variable S1 at the 9th position in variable S2. The changed text in S2 is displayed using ShowMessage.

ShowMessage shows: Testing insert today.

Note that there should be a space at the end of the text'Paste', otherwise the next word would be directly adjacent to the text to be pasted.