Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Variant Record Declaration
◄Keywords► ◄Contents► ◄Index► ◄Back►
CASE <tag field> OF <variant list>
Description
Every record has an optional field called a variant field. A
variant field, if it exists, is always the last field of a record;
it allows one field to store one of several data types. The
compiler sets aside enough memory to hold the largest data type
that the resulting variant field can hold.
The variant part begins with the CASE keyword and contains a
<tag field> and a <variant list> separated by the OF keyword.
The <tag field>
[ <identifier> : ] <ordinal type>
The <tag field> can begin with an optional identifier and colon.
The identifier must be of an ordinal type such as Boolean,
enumerated, or subrange types.
The <variant list>
<constant> [, <constant>, ... ] : ( [ <field list> ] );
.
.
<constant> [, <constant>, ... ] : ( [ <field list> ] )
A <variant list> contains one or more comma separated variant
fields. Each variant field contains one or more comma separated
constants, a colon, and a <field list>. The <field list> is
contained in parenthesis.
The <field list>
<identifier> [, <identifier>, ... ] : <any type>
The <field list> is what the variant record actually stores. It
contains one or more comma separated field declarations. Each
field declaration contains one or more comma separated
identifiers, a colon, and a type designator.
See also: Data Types Hierarchy