' ON ERROR — Error handling with GOTO/RESUME/ERR/ERL
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL ecode AS LONG

    ON ERROR GOTO ErrorHandler

    PRINT "Before error"
    ERROR 5
    PRINT "After error (should not print directly)"

    FUNCTION = 0

ErrorHandler:
    ecode = ERR
    PRINT "Error "; ecode; " at line "; ERL
    RESUME NEXT
END FUNCTION
