RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
System.Insert Function

Inserts a substring into a string beginning at a specified point.

Pascal
procedure Insert(Source: string; var S: string; Index: Integer);
C++
Insert(AnsiString Source, AnsiString S, int Index);

System

In Delphi code, Insert merges Source into S at the position S[index]. 

Source is a string-type expression. S is a string-type variable of any length. Index is an integer-type expression. It is a character index and not a byte index. 

If Index is less than 1, it is mapped to a 1. If it is past the end of the string, it is set to the length of the string, turning the operation into an append. 

If the Source parameter is an empty string, Insert does nothing. 

Insert throws an EOutOfMemory exception if it is unable to allocate enough memory to accomodate the new returned string. 

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!