I am developing on Mac with the last xojo release.
When I run on Window 10 my application I got a:
“Invalidargumentexception bad format”
runtime error on this line:
Var CalcArea_item_area As String = Areacmq_item.ToString(Locale.Current,“###.###,##”)
This line is running on Mac without any errors, but crash on Windows.
Any idea, I am the first sw who will run also on windows.
Thank you very much
According to the format that Xojo uses for ToString:
your format pattern should be
"###,###.##" and the locale should change the ‘,’ and ‘.’ to what the locale should use.
I’m not sure if that is the problem with your error and don’t know why it works on Mac and not on Windows.
Are the locales on your Mac and Windows machines the same? If not, do they both allow the . As a thousands separator and a , as a decimal separator?
Alberto pointed the correct universal format string where “.” is always at the decimal separator position while the results vary obeying the locale rules.
Probably due to some bug it is silently failing on the Mac and generating a wrong “formatted” value, and avoiding it while pointing the error on Windows. Is Areacmq_item a Double?
I have exactly the same apps on Mac and Windows. On Windows, I had to work extra to remove exceptions. Apparently, the platform is less tolerant than Mac.
I would say a bug. Different ICU libs and/or exception handling? Xojo, not OS.
Perhaps Xojo. I was simply reporting my experience.
A very welcomed one, I was just reporting a possible bug and inconsistency needing attention.
This information is in another topic.
In the means time I have found the solution:
On Mac was working in this way: “###.###,##” (European way to write double numbers)
But the formatted string need to be write in US way: “###,###.##”
Is not clear way on Mac do not raise an exception like on windows
Thank you to all
It does not make sense, it should cause wrong and invalid values.
Read the docs: Double — Xojo documentation
Tested this code and it runs without a problem on my mac:
Var Areacmq_item As Double = 1234.56
Var CalcArea_item_area As String = Areacmq_item.ToString(Locale.Current,"###.###,##")
And that’s is a wrong behavior. The mask does not follow the locale, the mask follows the Number Format Patterns, the result string follows the provided locale.
That’s a bug, not a feature. Windows is correct, Mac is wrong. Please open an Issue Report
@Sergio_Molino can you open a ticket for this? I don’t have a Windows machine to do screenshots (if needed).
Windows is correctly detecting a bad format
Once fixed, it works as stated in the ICU / Xojo docs
Mac and Linux should follow the standard.
Thank you Alberto to rise an issue.
The exception error on Windows was exactly that: “Bad format”
Confirmed on Mac, so thumbs up on the bug from me.