Tuesday 8 January 2013

Microsoft Dynamics AX 2012 R2 - any2Int Function


Converts an anytype value to an int value.


Function

  • int any2Int(anytype object)

Parameters

  • Parameter: object
  • Description: The value to convert.

Return Value

  • An int value.
The object parameter can be of most data types, but useful data is only obtained by using parameters of an enum, real, or str type.

 

Example

  • X++
static void any2IntExample(Args _args)
{
    int myInt;
    str s;
    NoYes a;
    real r;
    ;

    s = "31";
    myInt = any2Int(s);
    Global::info(strfmt("%1 is the output, from input of 31 as a str value.", myInt));

    a = NoYes::No;
    myInt = any2Int(a);
    Global::info(strfmt("%1 is the output, from input of NoYes::No as an enum value.", myInt));

    r = 5.34e2;
    myInt = any2Int(r);
    Global::info(strfmt("%1 is the output, from the input of 5.34e2 as a real value.", myInt));
 }
/**** Infolog display.
Message (02:23:59 pm)
31 is the output, from input of 31 as a str value.
0 is the output, from input of NoYes::No as an enum value.
534 is the output, from the input of 5.34e2 as a real value.
****/

My above blog is based on Microsoft's Official information.

I hope this blog about 'Microsoft Dynamics AX 2012 R2 - any2Int Function' was informative. Please feel free to leave your comments.

No comments:

Post a Comment