base.StringBuffer.insertAt

Insert a string at a given position.

Syntax

insertAt(
   index INTEGER,
   str STRING )
  1. index is the position where the string must be inserted.
  2. str is the string part to be inserted.

Usage

The insertAt() method inserts a string before the specified position in the string buffer.

Important: When using byte length semantics, the position is expressed in bytes. When using char length semantics, the unit is characters. This is matters when using a multibyte locale such as UTF-8.

Example

MAIN
   DEFINE buf base.StringBuffer
   LET buf = base.StringBuffer.create()
   CALL buf.append("abcdef")
   CALL buf.insertAt(3, "xx")
   DISPLAY buf.toString() -- Shows abcxxdef
END MAIN