Topic: Request: Rule for decimal mark  (Read 1287 times)

Request: Rule for decimal mark
« on: January 01, 2018, 12:59:33 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
Hi ied206,

We need a fixed (hardcoded) rule for decimal mark.

We had used dot ( . ) as decimal mark on plugins but one day a user came and decimal mark ( . )  did not work.
(a topic somewhere on http://theoven.org ... )
It seems decimal mark changed by hostos settings somehow effect old builder at one special hostos setting.

So we had to update plugins that are affected and create a Macro at Macro Library to overcome such situations.

As a begining:
1)
1a)
It is better PEBakery do NOT get decimal mark from hostos
ex:
https://resrequest.helpspot.com/index.php?pg=kb.page&id=279
and fixed decimal mark dot .

OR:

1b)
It is better PEBakery do NOT get decimal mark from hostos
ex:
https://resrequest.helpspot.com/index.php?pg=kb.page&id=279
and fixed decimal mark dot . OR comma ,


ps:
Reason behind 1b)
There are many multilanguage hostos default settings that have seperator comma ,
most important, multilanguage keyboard numberpad also writes comma , which some end users like to use that key for decimal seperator.


what you think ?

And whatever rule is, better written to help document.


ps: there are more cases related to this subject, one by one ....
http://theoven.org/index.php?topic=2271.msg25465#msg25465

Re: Request: Rule for decimal mark
« Reply #1 on: January 01, 2018, 02:12:12 PM »

ied206

  • Moderator,
  • Chef
  • *****
  • Location: South Korea
  • Date Registered: Jan 2014
  • Posts: 257
Hi ied206,

We need a fixed (hardcoded) rule for decimal mark.

We had used dot ( . ) as decimal mark on plugins but one day a user came and decimal mark ( . )  did not work.
(a topic somewhere on http://theoven.org ... )
It seems decimal mark changed by hostos settings somehow effect old builder at one special hostos setting.

So we had to update plugins that are affected and create a Macro at Macro Library to overcome such situations.
PEBakery follows solution 1a.
Reason: C#'s language-neutral number parsing is based on English, which allows '.' in decimal mark.

This snnipet is a code used in PEBakery to parse decimal number.
Code: [Select]
public static bool ParseDecimal(string str, out decimal value)
{
if (str.Equals(string.Empty, StringComparison.Ordinal))
{
value = 0;
return false;
}

if (str.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
{
bool result = ulong.TryParse(str.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out ulong intValue);
value = (decimal)intValue;
return result;

else
{
return decimal.TryParse(str, NumberStyles.AllowDecimalPoint | NumberStyles.Integer, CultureInfo.InvariantCulture, out value);
}
}

MSDN article clarifies:
Quote
The invariant culture is culture-insensitive; it is associated with the English language but not with any country/region.

Re: Request: Rule for decimal mark
« Reply #2 on: January 01, 2018, 02:22:30 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
Good I already like 1a) most   :thumbsup:

Can you add above info to help document.  :great:

See you on next post.....

Re: Request: Rule for decimal mark
« Reply #3 on: January 01, 2018, 02:26:24 PM »

Lancelot

  • Moderator, Gena Baker
  • Grand Chef
  • *****
  • Date Registered: Sep 2010
  • Posts: 10350
Hi ied206,

a related subject is where more than 1 decimal mark used.

Better PEBakery use only 1 decimal mark on "Math" commands and Halt if there is more than one.
reminding:
If,Bigger If,Smaller are math commands.
If,Equal is not a math command.

->
Reason behind: old builder let use more than 1 decimal mark which caused troubles later and fixed when reported....

What you think ?

 

Powered by EzPortal