Sample code for 30+ languages & platforms
PureBasic

StringTable SplitAndAppend Example

Demonstrates the StringTable SplitAndAppend method.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkStringTable.pb"

Procedure ChilkatExample()

    strTab.i = CkStringTable::ckCreate()
    If strTab.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    ; SplitAndAppend make it easy to break apart comma delimited, semicolon delimited,
    ; or strings delimited by other characters.
    s.s = "abc,123,xyz,456,music,math," + Chr(34) + "World History" + Chr(34) + "," + Chr(34) + "Chicago,Cubs" + Chr(34) + ",Japan"

    CkStringTable::ckSplitAndAppend(strTab,s,",",1,1)

    i.i = 0
    numStrings.i = CkStringTable::ckCount(strTab)
    While i < numStrings
        Debug Str(i) + ": " + CkStringTable::ckStringAt(strTab,i)
        i = i + 1
    Wend

    ; The output is: 
    ; 0: abc
    ; 1: 123
    ; 2: xyz
    ; 3: 456
    ; 4: music
    ; 5: math
    ; 6: "World History"
    ; 7: "Chicago,Cubs"
    ; 8: Japan

    ; Note: Keeping the quotes is intentional.


    CkStringTable::ckDispose(strTab)


    ProcedureReturn
EndProcedure