str2Num Function
Dynamics AX 2009
Converts a string to a real number.
real str2Num(str _text)
static void str2NumToReal(Args _arg)
{
real r;
str s;
;
r = str2Num("3.15");
s = strFmt("r = %1", r);
info(s);
}
/*** Infolog output.
Message_@SYS14327 (02:36:12 pm)
r = 3.15
***/
static void str2NumExponentialSyntax(Args _args)
{
Qty qty1, qty2, qty3;
;
qty1 = str2num('1e-3'); // Bad syntax by the user.
qty2 = str2num('1.e-3');
qty3 = str2num('1.0e-3');
info(strfmt('Result: %1; Expected: %2', num2str(qty1, 0,3,2,0), '0.001'));
info(strfmt('Result: %1; Expected: %2', num2str(qty2, 0,3,2,0), '0.001'));
info(strfmt('Result: %1; Expected: %2', num2str(qty3, 0,3,2,0), '0.001'));
}
/*** Infolog output. The first result differs from expectations.
Message_@SYS14327 (02:20:55 pm)
Result: 1,000; Expected: 0.001
Result: 0,001; Expected: 0.001
Result: 0,001; Expected: 0.001
***/
Community Additions
ADD
Show: