Xbase++
Xbase++
StringBuilder SetNth
Demonstrates the SetNth method.Chilkat Xbase++ Downloads
LOCAL oSb
LOCAL cDelimiterChar
LOCAL nExceptDoubleQuoted
LOCAL nExceptEscaped
// The SetNth method is handy for setting a part of a delimited string.
// For example:
oSb := CreateObject("Chilkat.StringBuilder")
oSb:Append('red,blue,"green,purple",,yellow')
cDelimiterChar := ","
nExceptDoubleQuoted := 1
nExceptEscaped := 1
oSb:SetNth(2, "magenta", cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped)
// Prints "red,blue,magenta,,yellow"
? oSb:GetAsString()
oSb:SetNth(3, "orange", cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped)
// Prints "red,blue,magenta,orange,yellow"
? oSb:GetAsString()
// What happens if we start with an empty string?
oSb:Clear()
oSb:SetNth(2, "apple", cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped)
// Prints ",,apple"
? oSb:GetAsString()
oSb:SetNth(0, "orange", cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped)
// Prints "orange,,apple"
? oSb:GetAsString()
oSb:SetNth(1, "banana", cDelimiterChar, nExceptDoubleQuoted, nExceptEscaped)
// Prints "orange,banana,apple"
? oSb:GetAsString()
oSb:destroy()