The equals sign in a UDT causes the element offset counter to be reset. This allows any number of unions to be defined within a type.
[code=thinbasic]
'USER DEFINED TYPES
'UNION
uses "oxygen","file"
dim src as string
src = "
type color32
r as byte
g as byte
b as byte
a as byte
=
rgba as long 'UNION
end type
dim c as color32
c.r=16
c.b=16
c.g=16
c.a=32
print hex c.rgba
print hex c.a
terminate
"
o2_basic src
'msgbox 0, o2_view "o2h "+src
if len(o2_error) then
msgbox 0, o2_error : stop
end if
o2_exec
[/code]
Bookmarks