' Pointer arithmetic: PTR type, pointer operations, offset access
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL arr(0 TO 9) AS LONG
    LOCAL i  AS LONG
    LOCAL sum  AS LONG
    LOCAL val0  AS LONG
    LOCAL val1  AS LONG
    LOCAL p AS LONG

    FOR i = 0 TO 9
        arr(i) = i * 10
    NEXT i

    p = VARPTR(arr(0))
    PRINT "Base pointer:"; p
    PRINT "SIZEOF(LONG):"; SIZEOF(LONG)

    val0 = PEEK(DWORD, p)
    val1 = PEEK(DWORD, p + 4)
    PRINT "arr(0):"; val0
    PRINT "arr(1):"; val1
    sum = val0 + val1
    PRINT "arr(0) + arr(1):"; sum

    PRINT "Pointer arithmetic complete."

    FUNCTION = 0
END FUNCTION
