' UNION/END UNION and ENUM/END ENUM definitions
#COMPILE EXE
#DIM ALL

TYPE Variant
    UNION
        b AS BYTE
        w AS WORD
        l AS LONG
    END UNION
END TYPE

ENUM Colors
    Red = 1
    Green = 2
    Blue = 3
END ENUM

FUNCTION PBMAIN() AS LONG
    LOCAL v AS Variant
    LOCAL c AS LONG

    v.l = &H12345678
    PRINT "UNION as LONG:"; FORMAT$(v.l, "&H")
    PRINT "UNION as WORD(lo):"; FORMAT$(v.w, "&H")
    PRINT "UNION as BYTE(lo):"; FORMAT$(v.b, "&H")

    c = Red
    PRINT "ENUM Red:"; c
    PRINT "ENUM Green:"; Green
    PRINT "ENUM Blue:"; Blue

    PRINT "UNION/ENUM operations complete."

    FUNCTION = 0
END FUNCTION
