base.StringBuffer.getCharAt

Return the character at a specified position.

Syntax

getCharAt(
   position INTEGER )
  RETURNING result STRING
  1. position is the character position in the string.

Usage

The getCharAt() method returns the character from the string buffer at the position that you specify.

The first character position is 1.

The method returns NULL if the position is lower as 1 or greater as the length of the string.

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

DEFINE buf base.StringBuffer 
LET buf = base.StringBuffer.create()
CALL buf.append("abcdef")
DISPLAY buf.getCharAt(3)  -- Shows c