Sample code for 30+ languages & platforms
PowerBuilder

StringBuilder GetNth

Demonstrates the GetNth method.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
oleobject loo_Sb
string ls_DelimiterChar
integer li_ExceptDoubleQuoted
integer li_ExceptEscaped

// The GetNth method is handy for getting parts from delimited strings.
// For example:

loo_Sb = create oleobject
li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
    destroy loo_Sb
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Sb.Append("red,blue,~"green,purple~",,yellow")

ls_DelimiterChar = ","
li_ExceptDoubleQuoted = 1
li_ExceptEscaped = 1

// Prints "[red]"
Write-Debug "[" + loo_Sb.GetNth(0,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"

// Prints "[blue]"
Write-Debug "[" + loo_Sb.GetNth(1,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"

// Prints "[green,purple]"
Write-Debug "[" + loo_Sb.GetNth(2,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"

// Prints "[]"
Write-Debug "[" + loo_Sb.GetNth(3,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"

// Prints "[yellow]"
Write-Debug "[" + loo_Sb.GetNth(4,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"

// Prints "[]"
Write-Debug "[" + loo_Sb.GetNth(5,ls_DelimiterChar,li_ExceptDoubleQuoted,li_ExceptEscaped) + "]"


destroy loo_Sb