' Nested TYPE definitions: TYPE containing TYPE, UNION inside TYPE, TYPEDEF
#COMPILE EXE
#DIM ALL

TYPE Person
    firstName AS STRING
    lastName AS STRING
END TYPE

TYPE Address
    street AS STRING
    city AS STRING
    zip AS STRING
END TYPE

TYPE Employee
    id AS LONG
    personal AS Person
    addr AS Address
    UNION
        hourlyRate AS DOUBLE
        annualSalary AS DOUBLE
    END UNION
END TYPE

FUNCTION PBMAIN() AS LONG
    LOCAL emp AS Employee
    LOCAL fn  AS STRING
    LOCAL ln  AS STRING
    emp.id = 101
    emp.personal.firstName = "Alice               "
    emp.personal.lastName = "Smith               "
    emp.addr.city = "Portland                         "

    PRINT "Employee ID:"; emp.id
    PRINT "First:"; TRIM$(emp.personal.firstName)
    PRINT "Last:"; TRIM$(emp.personal.lastName)
    PRINT "SIZEOF(Employee):"; SIZEOF(emp)

    PRINT "Nested TYPE operations complete."

    FUNCTION = 0
END FUNCTION
