Click to Rate and Give Feedback
MSDN
MSDN Library
Microsoft Dynamics
Data Types in X++
 Anytype [AX 2012]
Collapse All/Expand All Collapse All
Microsoft Dynamics AX 2012
Anytype [AX 2012]

The anytype data type is a placeholder for any data type. Variables of type should only be used as arguments and return values.

If anytype is used as a variable, you must assign a value to it before it can be used or you will get a run-time error. After you have assigned a value to it, you cannot convert it to another data type.

The range of an anytype variable depends on the value first assigned to it. For example, if an integer is assigned, the range of the variable will then be [-2.147.483.647 ; 2.147.483.647].

anytype declaration

=

anytype Variable { , Variable } ;

variable

=

identifier [ option ]

option

=

arrayoptions | initialization

The anytype data types can be automatically converted to dates, enums, integers, reals, strings, guids, int64s, extended data types (records), classes, and containers by assigning a value to the type. For example:

X++
anytype a;
;
a = "text";  // Assigns a string literal

However, after you have converted the anytype data type, you cannot then change it to another data type.

You can use anytype variables in expressions. You can also use them in the same way that you can use the data type that you convert them to. For example, if you assign an integer, you can then apply relational and arithmetic operators to the variable.

However, anytype is usually used as arguments and return types. For example:

X++
public static str range(anytype _from, anytype _to)
{
    return queryValue(_from) + '..' + queryValue(_to);
}

and

X++
void put(int position, anytype data)
{
    record = conpoke(record, position, data);
}

Keyword

anytype

Size

Depends on conversion type

Scope of data type

Depends on conversion type

Default value

Depends on conversion type

Implicit conversions

Automatically converted to dates, enums, integers, reals, strings, extended data types (records), classes, and containers

Explicit conversions

any2date, any2enum, any2int, any2real, any2str

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker