RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiString::Insert Method

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

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

System::AnsiString::Insert inserts the string str into this System::AnsiString::AnsiString 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::AnsiString::Insert does nothing. 

System::AnsiString::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) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!