Extended Data Types

Extended data types are user-defined types, based on the primitive data types Boolean, integer, real, string, and date, and the composite type container. You can also base extended data types on other extended data types.

This feature is not implemented as a language construct. Extended data types are defined in the Application Object Tree (AOT).

An extended data type is a primitive data type or container with a supplementary name and some additional properties. For example, you could create a new type called Name on the basis of string and thereafter use the new type in variable and field declarations in the development environment.

The advantages of extended data types are as follows:

  • Code is easier to read because variables have a meaningful data type. For example, Name instead of string.

  • The properties you set for an extended data type are used by all instances of that type, which reduces work and promotes consistency. For example, account numbers (AccountNum data type) have the same properties throughout the system.

  • You can create hierarchies of extended data types, inheriting the properties that are appropriate from the parent and changing the other properties. For example, the ItemCode data type is used as the basis for the MarkupItemCode and PriceDiscItemCode data types.

Range and Precision

The range of an extended data type is identical to that of the base type it is based on.

Declaration of Extended Data Type Variables

The Extended Data Types node below the Data Dictionary node in the AOT is used to create extended data types. When declaring variables in X++, use the syntax shown in the following table.

Extended declaration

=

Extendedtype Variable { , Variable } ;

Variable

=

Identifier [ option ]

Option

=

arrayoptions | initialization

where Extendedtype is the name of the extended data type in the AOT.

// A UserGroupID (integer) variable is declared and initialized to 1

UserGroupID groupID = 1;

// An Amount (real) variable is declared

Amount currency;

Automatic Conversion

Because extended data types are normal data types but with a specific name and properties, all standard conversions are performed.

See Also

Containers

Conversion of Data Types

Primitive Data Types