I am stuck, trying to pass some data to a webservice that requires the data to have two decimal places.
I have made some reading and turned my variables to currency (they are obviously representing currency values) and I saved all that in my database as currency with FOUR decimal places. That seems to be fine.
Now, what’s the right approach to pass that data to the webservice with only two decimal places ?
I am probably doing something wrong, it’s my first time with money…
The data you pass to a webservice is in the form of a STRING. It doesn’t matter how it is stored in your application, you have to convert/format it in order to pass it to a webservice. So format it with 2 decimal places and you’re good to go.
The only wrinkle is whether the service is expecting an explicit decimal point, “1234.56”, or an implied decimal point, “123456”.
[quote=263775:@Roman Varas]I think the problem is related to the locale setting… here we use comma for decimals…
[/quote]
Use Str with a format string that ALWAYS uses , and . regardless of locale
[quote=263773:@Roman Varas]
But “format” inserts a comma in the string[/quote]
Instead of using the format method use STR http://documentation.xojo.com/index.php/Str
It also allows you to use a format string BUT it never uses anything but “american settings” - , for thousands and . for decimal
If you make the format string “#######.00” then you get no thousands separators & a period for the decimal separator