formattedstr2Num Function
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:
-
real formattedstr2Num("123.45") returns the value 123.45.
-
real formattedstr2Num("a123") throws the error Exception::Numeric.
-
int formattedstr2Num("123,000") returns the value 123000.
-
real formattedstr2Num("123000") returns the value 123,000.00.
-
real formattedstr2Num("123+45,000") returns the value 45,123.00.