' String Basics — LEN, LEFT$/RIGHT$/MID$, INSTR
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL text AS STRING
    LOCAL result AS STRING
    LOCAL pos AS LONG

    text = "The quick brown fox"

    PRINT "Source text: " + text
    PRINT "LEN: " + STR$(LEN(text))
    PRINT

    result = LEFT$(text, 3)
    PRINT "LEFT$(text, 3):  " + result

    result = RIGHT$(text, 3)
    PRINT "RIGHT$(text, 3): " + result

    result = MID$(text, 5, 5)
    PRINT "MID$(text, 5, 5):" + result

    result = MID$(text, 11)
    PRINT "MID$(text, 11):  " + result

    pos = INSTR(text, "brown")
    PRINT "INSTR(text,brown): " + STR$(pos)

    pos = INSTR(5, text, "o")
    PRINT "INSTR(5,text,o):   " + STR$(pos)

    pos = INSTR(10, text, "o")
    PRINT "INSTR(10,text,o):  " + STR$(pos)

    IF INSTR(text, "fox") > 0 THEN
        PRINT "Found fox in text."
    END IF

    FUNCTION = 0
END FUNCTION
