Summary:
See also: Built-in classes
The StringBuffer class is a built-in class designed to manipulate character strings.
base.StringBuffer
Class Methods | |
Name | Description |
create( ) RETURNING base.StringBuffer |
Creates a new empty StringBuffer object. |
Object Methods | |
Name | Description |
append( str STRING ) |
Appends a string to the string buffer. |
clear( ) |
Clears the string buffer. |
equals( src STRING ) RETURNING INTEGER |
Returns TRUE if the string passed as parameter matches the current string. If one of the strings is NULL the method returns FALSE. |
equalsIgnoreCase( src STRING ) RETURNING INTEGER |
Returns TRUE if the string passed as parameter matches the current string, ignoring character case. If one of the strings is NULL the method returns FALSE. |
getCharAt( pos INTEGER ) RETURNING STRING |
Returns the character at the position pos (starts at 1). Returns NULL if the position does not match a character position in the current string. |
getIndexOf( str STRING, spos INTEGER
) RETURNING INTEGER |
Returns the position of the sub-string str in the current string, starting from position spos. Returns zero if the sub-string was not found. |
getLength( ) RETURNING INTEGER |
Returns the number of characters of the current string, including trailing spaces. |
subString( spos INTEGER, epos INTEGER ) RETURNING STRING |
Returns the sub-string starting at spos and ending at epos. Returns NULL if the positions do not delimit a sub-string in the current string. First character position is 1. |
toLowerCase( ) |
Converts the current string to lowercase. |
toUpperCase( ) |
Converts the current string to uppercase. |
trim( ) |
Removes white space characters from the beginning and end of the current string. |
trimLeft( ) |
Removes white space characters from the beginning of the current string. |
trimRight( ) |
Removes white space characters from the end of the current string. |
replaceAt( pos INTEGER, len INTEGER,
str STRING ) |
Replaces a part of the current string by another string, starting from position pos for len characters. First character position is 1. |
replace( oldString STRING,
newString STRING, occ INTEGER ) |
Replaces in the current string the STRING oldString by the STRING newString, occ time(s) (all occurrences, if occ set to 0). |
insertAt( pos INTEGER, str STRING
) |
Inserts a string before the position pos. First character position is 1. |
toString( ) RETURNING STRING |
Creates a STRING value from the current buffer. |
STRING.append()
method, the runtime system creates a new buffer to hold the new string. When
using a StringBuffer object, you modify the current buffer. This class is
particularly useful in writing library functions.01
MAIN02
DEFINE buf base.StringBuffer03
LET buf = base.StringBuffer.create()04
CALL buf.append("abc")05
DISPLAY buf.toString()06
CALL buf.append("def")07
DISPLAY buf.toString()08
CALL buf.append(123456)09
DISPLAY buf.toString()10
END MAIN
01
MAIN02
DEFINE buf base.StringBuffer03
LET buf = base.StringBuffer.create()04
CALL modify(buf)05
DISPLAY buf.toString()06
END MAIN07
08
FUNCTION modify(sb)09
DEFINE sb base.StringBuffer10
CALL sb.append("more")11
END FUNCTION