View Single Post
  #26  
Old November 2nd, 2006, 05:11 AM

Devnullicus Devnullicus is offline
Sergeant
 
Join Date: Feb 2001
Location: Belmont, CA USA
Posts: 285
Thanks: 0
Thanked 0 Times in 0 Posts
Devnullicus is on a distinguished road
Default Re: Space Empires V Editor 1.0 released

ok, got it. Man, what a pain in the ***. Turns out I was correctly NOT using regional settings when parsing the formula, BUT C# was using them anyway when doing a Convert. So, it was doing very strange things with . and , characters when the regional settings were different.

The fix was to just set the app settings to en-US Number Formatting. Figuring out how to DO that, however, was a real pain in the ***. Ah well, it should work now.

Just in case any other C# programmers want to know how to force an application to use US number formatting no matter what the user's regional settings are, here's some code

Code:

CultureInfo currentCultureInfo = Thread.CurrentThread.CurrentCulture;
CultureInfo cultureInfo = (CultureInfo)currentCultureInfo.Clone();
NumberFormatInfo nfi = new CultureInfo( "en-US", false ).NumberFormat;
cultureInfo.NumberFormat = nfi;
Thread.CurrentThread.CurrentCulture = cultureInfo;



Wouldn't be nearly so annoyingly difficult to figure out if the system didn't make the original settings read-only so that I had to clone them. Sheesh.
__________________
How's my Programming? Call 1-800-DEV-NULL
Get the Space Empires V Editor and DevnullMod at http://www.devnullsoftware.com/se5
Reply With Quote