str2Num Function

Converts a text string to a real number. Scanning occurs from left to right and terminates when a character cannot be converted to part of a real number.


real str2Num(str _text)

Parameter

Description

_text

The string to be converted to a real number.

The real number that represents text. Zero is returned if the text does not contain a valid number. Following are examples:

  • str2Num("123.45") returns the value 123.45.

  • str2Num("a123") returns the value 0.0.

  • str2Num("123a") returns the value 123.00.

static void str2NumExample(Args _arg)
{
    real r;
    ;
    r = str2Num("3.15");
    print strFmt("r = %1", r);
    pause;
}

Community Additions

ADD
Show: