' file_constants.pb — File system constants and operations
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL fileAttr AS LONG
    LOCAL fileMode AS LONG
    LOCAL fileAction AS LONG
    LOCAL filePos AS LONG
    LOCAL fileSize AS LONG
    LOCAL i AS LONG
    LOCAL j AS LONG
    LOCAL totalOps AS LONG
    LOCAL readOps AS LONG
    LOCAL writeOps AS LONG
    LOCAL seekOps AS LONG
    LOCAL modeStr AS STRING
    LOCAL attrStr AS STRING
    LOCAL actionStr AS STRING
    LOCAL iter AS LONG
    LOCAL numOperations AS LONG
    LOCAL opType AS LONG
    LOCAL result AS LONG

    numOperations = 15

    PRINT "=== File Constants System ==="

    FOR totalOps = 1 TO numOperations
        opType = totalOps MOD 5

        IF opType = 0 THEN
            fileMode = 1
            fileAction = 1
            modeStr = "READ"
            actionStr = "OPEN_EXISTING"
            readOps = readOps + 1
        END IF

        IF opType = 1 THEN
            fileMode = 2
            fileAction = 2
            modeStr = "WRITE"
            actionStr = "CREATE_ALWAYS"
            writeOps = writeOps + 1
        END IF

        IF opType = 2 THEN
            fileMode = 3
            fileAction = 0
            modeStr = "APPEND"
            actionStr = "OPEN_ALWAYS"
            writeOps = writeOps + 1
        END IF

        IF opType = 3 THEN
            fileMode = 1
            fileAction = 3
            seekOps = seekOps + 1
            filePos = totalOps * 100
            PRINT "  SEEK: pos=" + STR$(filePos) + " (FILE_BEGIN)"
        END IF

        IF opType = 4 THEN
            fileAttr = totalOps
            IF fileAttr = 1 THEN attrStr = "FILE_ATTRIBUTE_NORMAL"
            IF fileAttr = 2 THEN attrStr = "FILE_ATTRIBUTE_READONLY"
            IF fileAttr = 3 THEN attrStr = "FILE_ATTRIBUTE_HIDDEN"
            IF fileAttr = 4 THEN attrStr = "FILE_ATTRIBUTE_SYSTEM"
            IF fileAttr = 5 THEN attrStr = "FILE_ATTRIBUTE_DIRECTORY"
            IF fileAttr = 6 THEN attrStr = "FILE_ATTRIBUTE_ARCHIVE"
            IF fileAttr = 7 THEN attrStr = "FILE_ATTRIBUTE_TEMPORARY"
            IF fileAttr = 8 THEN attrStr = "FILE_ATTRIBUTE_COMPRESSED"
            IF fileAttr = 9 THEN attrStr = "FILE_ATTRIBUTE_ENCRYPTED"
            IF fileAttr = 10 THEN attrStr = "FILE_ATTRIBUTE_SPARSE_FILE"
            IF fileAttr = 11 THEN attrStr = "FILE_ATTRIBUTE_REPARSE_POINT"
            IF fileAttr = 12 THEN attrStr = "FILE_ATTRIBUTE_OFFLINE"
            IF fileAttr = 13 THEN attrStr = "FILE_ATTRIBUTE_NOT_CONTENT_INDEXED"
            IF fileAttr > 13 THEN attrStr = "CUSTOM_ATTRIBUTE"
            PRINT "  ATTR: " + attrStr + " (value=" + STR$(fileAttr) + ")"
        END IF

        IF opType = 0 THEN
            PRINT "  OPEN: mode=" + modeStr + " action=" + actionStr
        END IF
        IF opType = 1 THEN
            PRINT "  OPEN: mode=" + modeStr + " action=" + actionStr
        END IF
        IF opType = 2 THEN
            PRINT "  OPEN: mode=" + modeStr + " action=" + actionStr
        END IF
    NEXT totalOps

    PRINT "--- Summary ---"
    PRINT "Reads: " + STR$(readOps) + " Writes: " + STR$(writeOps) + " Seeks: " + STR$(seekOps)
    PRINT "Total: " + STR$(numOperations)
    PRINT "=== End File Constants ==="
    FUNCTION = 0
END FUNCTION
