Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Futurebasic/Language/Reference/begin union

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

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$ = "COW" print myTest.inUnion1 The variable myTest.inUnion1 is a single byte which occupies the same space as the first byte in the string myTest.inUnion2$. In this case, myTest.inUnion1 happens to be the length byte of the string and the print 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 begin union statement, all dims up to the end union 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. Notes No special notes. See Also dim record...dim end record; dim; begin record Language Reference