Futurebasic/Language/Reference/begin union

Statement
✔ Appearance ✔  Standard ✔  Console

Syntax
begin record recordName dim statements... begin union dim statements end union end record

Description
A union is used to set aside space in a record that may potentially contain more than one size variable. The following example sets aside two equal offsets within a record for variables of differing sizes: begin record RecordWithUnion dim beforeUnion begin union dim inUnion1` dim inUnion2$ end union end record dim myTest as RecordWithUnion myTest.inUnion2$ = &quot;COW&quot; print myTest.inUnion1 The variable  is a single byte which occupies the same space as the first byte in the string. In this case,  happens to be the length byte of the string and the   statement will produce "3". Such an overlap is not necessary and the two values may have no relation to one another except that they start at the same location in memory.

When FB encounters a  statement, all  s up to the   statement are examined and the largest item in the union determines the amount of space set aside by the compiler. In the example above, the union would occupy 256 bytes since the largest element in the union is a 256 byte Pascal string.