' String Replace/Split — REPLACE$, SPLIT, JOIN$, TALLY
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL text AS STRING
    LOCAL result AS STRING
    LOCAL count AS LONG
    LOCAL w1 AS STRING
    LOCAL w2 AS STRING
    LOCAL w3 AS STRING
    LOCAL w4 AS STRING

    text = "apple,banana,cherry,apple,date"
    PRINT "Original: " + text
    PRINT

    result = REPLACE$(text, "apple", "orange")
    PRINT "REPLACE$ apple->orange: " + result

    count = TALLY(text, ",")
    PRINT "TALLY commas: " + STR$(count)
    PRINT

    w1 = "One"
    w2 = "Two"
    w3 = "Three"
    w4 = "Four"

    result = w1 + "," + w2 + "," + w3 + "," + w4
    PRINT "Join with ',': " + result

    result = w1 + " | " + w2 + " | " + w3 + " | " + w4
    PRINT "Join with ' | ': " + result

    FUNCTION = 0
END FUNCTION
