RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringBase::Insert Method

System::AnsiStringBase::Inserts a specified string into the System::AnsiStringBase.

Pascal
function Insert(const str: AnsiStringBase&; index: Integer): AnsiStringBase&;
C++
__fastcall AnsiStringBase& Insert(const AnsiStringBase& str, int index);

System::AnsiStringBase::Insert inserts the string str into this System::AnsiStringBase beginning at the position index, where 1 is the first position in the string. It returns the resulting modified string (*this). 

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 Length(), turning the operation into an append. 

If the str parameter is an empty string, System::AnsiStringBase::Insert does nothing. 

System::AnsiStringBase::Insert throws an EOutOfMemory exception if the method is unable to allocate enough memory to accommodate the new, longer, string.

Note: The index parameter specifies the character, not the byte, when working with a multi-byte character system.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!