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

Insert

Insert one string in another.

Declaration

Source position: line 0

procedure Insert(

  const source: shortstring;

  var s: shortstring;

  index: SizeInt

);

procedure Insert(

  source: Char;

  var s: shortstring;

  index: SizeInt

);

procedure Insert(

  const Source: AnsiString;

  var S: AnsiString;

  Index: SizeInt

);

procedure Insert(

  const Source: UnicodeString;

  var S: UnicodeString;

  Index: SizeInt

);

procedure Insert(

  const Source: WideString;

  var S: WideString;

  Index: SizeInt

);

Description

Insert inserts string Source in string S, at position Index, shifting all characters after Index to the right. The resulting string is truncated at 255 characters, if needed. (i.e. for shortstrings)

Errors

None.

See also

Delete

  

Delete part of a string.

Copy

  

Copy part of a string.

Pos

  

Search for substring in a string.

Example

Program Example33;

{ Program to demonstrate the Insert function. }

Var S : String;

begin
  S:='Free Pascal is difficult to use !';
  Insert ('NOT ',S,pos('difficult',S));
  writeln (s);
end.
The latest version of this document can be found at lazarus-ccr.sourceforge.net.