Name

Insert Procedure

Syntax

procedure Insert(const Ins: string; var Str: string; Index: Integer);

Description

The Insert procedure inserts the string Ins into the string Str at the position Index. If Index is ≤ 1, Ins is inserted at the beginning of Str. If Index is past the end of the string, Ins is appended to the end of Str.

Insert is not a real procedure.

Tips and Tricks

The first character of a string has index 1.

Example

// Insert a drive letter at the front of a path.
procedure InsertDriveLetter(var Path: string; const Drive: Char);
begin
  // First make sure the path does not have a drive letter in front.
  if (Length(Path) < 2) or (Path[2] <> ':') then
    // Insert the drive at the start of the path.
    Insert(Drive + ':', Path, 1);
end;

See Also

Copy Function, Delete Procedure, SetLength Procedure, SetString Procedure
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset