formattedStr2Num Function [AX 2012]
Updated: December 10, 2009
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
Converts a semi-numeric string into a real number.
real formattedstr2Num(str _text)
Zero is returned if the text does not contain a valid number.
The string can contain expressions or formulas consisting of real literals, such as 0.04.
Arithmetic operators that the follow standard arithmetic precedence rules, such as "+" and "/" can be used. You can use sub-expressions to modify the evaluation order, for example, 6+(5-2). An expression can also contain a minus, such as -1.0 or –(4-7). Spaces are ignored.
The numbers in the string may contain separator symbols, such as a comma or decimal.
Exponential notation, such as 1.2E+2, is not supported. If the expression contains an error (like (1+2)*+4), the numeric exception will be thrown. Otherwise, the function result is the value of the expression.
The following examples show return values:
-
formattedstr2Num("123.45") //Returns the real value 123.45.
-
real formattedstr2Num("a123") //Causes the error Exception::Numeric.
-
int formattedstr2Num("123,000") //Returns the int value 123000.
-
formattedstr2Num("123000") //Returns the real value 123,000.00.
-
formattedstr2Num("123+45,000") //Returns the real value 45,123.00.
Announcements: To see known issues and recent fixes, use Issue search in Microsoft Dynamics Lifecycle Services (LCS).