' String operations
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL a AS STRING
    LOCAL b AS STRING
    LOCAL c AS STRING
    LOCAL err AS LONG
    a = "Hello"
    b = "World"
    c = a + " " + b
    IF c <> "Hello World" THEN err = 1

    IF UCASE$("abc") <> "ABC" THEN err = 2
    IF LCASE$("XYZ") <> "xyz" THEN err = 3
    IF TRIM$("  spaced  ") <> "spaced" THEN err = 4

    IF LEFT$("Hello", 2) <> "He" THEN err = 5
    IF RIGHT$("Hello", 2) <> "lo" THEN err = 6
    IF MID$("Hello", 2, 2) <> "el" THEN err = 7

    IF ASC("A") <> 65 THEN err = 8
    IF CHR$(66) <> "B" THEN err = 9

    IF err = 0 THEN
        PRINT "All string ops passed"
    ELSE
        PRINT "Error code: " + STR$(err)
    END IF
    FUNCTION = 0
END FUNCTION
