Navigation:  thinBasic language > Data types and variables >

UNION

Previous pageReturn to chapter overviewNext page

 

Description

 

Define a User-Defined Data Type (UDT), containing one or more member elements.

UNION differs from TYPE because elements inside an UNION always share the same memory block.

 

Syntax

 

UNION MyUnion

[MemberName AS TypeName]

[MemberArrayName[(nElements)] AS TypeName]

[...]

END UNION

 

Returns

 

None

 

Parameters

 

Remarks

 

Restrictions

 

In case of string element, it is mandatory to specify a fixed size string.

 

See also

 

Examples

 

UNION tUnion

  b(12)   As Byte

  st      As ASCIIZ * 12

End UNION

 

Dim MyU As tUnion

MyU.b( 1) = 84

MyU.b( 2) = 104

MyU.b( 3) = 105

MyU.b( 4) = 110

MyU.b( 5) = 66

MyU.b( 6) = 97

MyU.b( 7) = 115

MyU.b( 8) = 105

MyU.b( 9) = 99

MyU.b(10) = 32

MyU.b(11) = 33

 

MSGBOX 0, MyU.st

 

 

© 2004-2008 thinBasic. All rights reserved. Version 1.7.0.0 Web Site: http://www.thinbasic.com