any2Int Function

Converts an anytype value to an int value.


int any2Int(anytype object)

Parameter

Description

object

The value to convert.

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.

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.
****/

Community Additions

ADD
Show: