RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
AnsiStringT::Insert Method

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

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

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

System::AnsiStringT::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!