Gossamer Forum
Home : Products : DBMan : Customization :

...number formatting...

Quote Reply
...number formatting...
Hello all.

First of all I must say that reading the board helped me to build a very nice DB for one of my customers. They liked so much the work that they asked me to make a large number of customization. Well, at this point I'm stopped with a problem with numbers. I've already read all the topics I found but I did not reach my goal.

The DB has a field for the price and I need to place an automatic conversion from Lire to Euro, I mean that the client put the price and automatically the script calculate the price in Euro.

The code I found in the board that I'm using at this moment is this:

---------------------------------------
$valuta = sprintf ("%.2f" , ($rec{'Prezzo'} / 1936.27));
1 while $rec{'Prezzo'} =~ s/(\d)(\d{3})\b/$1.$2/;
1 while $valuta =~ s/^([-+]?\d+)(\d{3})/$1.$2/;
$valuta =~ s/\/./,/;
----------------------------------------

This code take the price in Lire and format it from 100000 to 100.000, take the value from Lire and convert it to Euros.

The problem is that the field "Prezzo" appears correctly formatted in european format, but the price in Euro does not appear correctly.

I need that the price in Euro appears like:
1.000,32 and not like in the US 1,000.32

Hope to hear from someone soon. Smile







------------------
Marco
Quote Reply
Re: ...number formatting... In reply to
Try this. After

$valuta =~ s/\/./,/;

add

substr($valuta,-3,1) = ',';

That will replace the '.' with a ','.

It seemed to work when I ran it through Perl. At least it's something to try. Smile



------------------
JPD






Quote Reply
Re: ...number formatting... In reply to
JPDeny,

reading your post helped me a lot, reading this post to me, saved my life Smile

thanks alot, it worked at the first attempt.




------------------
Marco
Quote Reply
Re: ...number formatting... In reply to
Cool! I wasn't really sure how to do it and then I remembered something I saw in a book when I was looking for something else.

Glad I could help.


------------------
JPD






Quote Reply
Re: ...number formatting... In reply to
Thanks to you!

I've walked thru the forum for a week and reading your posts helped me make a really cool job for my customer, and I learn a lot about DBman. You make this forum better than a FAQ Smile

Thanks again.


------------------
Marco