Printing number in French format

Is there a way to specify the language while printing a number.

The below code prints “123.66”


real i = 123.66;
print i;


I want to print this number as “123,66”

Is there any X++ function which does this format change?

Thanks in advance,
Sasi

Yes, use num2str() function to format the actual string output of the number.

real i = 123.66;

print num2str(i,9,2,","," ");

Read more here:

http://msdn.microsoft.com/en-us/library/aa866120.aspx

Hi Janis,

You are right, I can use num2str() function for formatting real numbers.

I wanted to know whether there is any X++ function which takes the language and the real number as input and does the formatting automatically.

Thanks,

Sasi

There is no such thing decimal separators settings per countries.

If you are keen, you can do a simple modification - add an ENUM field DecimalSeparator to AddressCountryRegion table allowing just values “.” and “,”.

Then just use your specific formatting approach in code like this:

print num2str(i,9,2,AddressCountryRegion::find(“FR”).DecimalSeparator," ");

Thanks a lot for your suggestion. This increases my work [:)], but it is a good way to format numbers.

Thanks,

Sasi