Convert string to real

Hi All,

I need to convert string to real value. The string value comes from file, something like “$56,729”. This value should be converted to real value. Is any built in function available to achieve this ? I tried using any2real() and str2num() functions, both returned value “56.00”. The output value should be “56,729.00”.

Regards,

Raghav.

Hi,

Well, since you’ve been already getting a result of 56.00, you should have had a feeling that you are getting close. Problem’s being caused by a thousand separator “,”. Format the string (remove that thousand separator) before passing it to str2num() and it will work:

static void Job99(Args _args)

{

Str myNumber = “56,729.01”;

Real output;

;

myNumber = strrem(myNumber, “,”);

output = str2num(myNumber);

info(strfmt(“Output: %1”, output));

}

Janis