Validator for numerical input fields

Hi Marton, all,

I am using Molflow+ with Ubuntu18.04. I am very happy that you made Molflow available for Linux, so thanks a lot! :-)

The GUI uses a comma as a decimal separator, isn't it? This is not a problem in itself, but some people (like me :-) is used to use a point instead of a comma, and for some numerical input fields in Molflow+ this does not generate an error, but just ignores the decimals. This might unintentionally lead to wrong results.

So I would propose that all the numerical input fields have a validator that checks that just the allowed signs are given and raise an error otherwise.

A place where this should be implemented is the new tool to create shapes from within Molflow (by the way, thanks a lot for this new feature!!!), specially because it is very useful and convenient to use if you don't have a consistent framework to generate .stl files, and I expect that it will be broadly used.

Best regards,

Pau Gonzalez

PD: I didn't know where to report this behaviour... It's not really a bug, but it can lead to errors.

Hello Pau,

No, Molflow (should) use DOT as decimal separator, and also throw an error on incorrect formats.

Can you show an example (like a screenshot) where comma is accepted?

I've tested (in Windows) and both text and commas are rejected:

2020-02-14 17_04_28-Molflow+ 2.7.10 (Dec 19 2019) [].png

2020-02-14 17_04_46-Molflow+ 2.7.10 (Dec 19 2019) [].png

Let me know, also the Molflow version you use, and next week I'll set up an Ubuntu test machine.

Hi Marton,

Okay, that's strange...

Molflow+ 2.7.10 with Ubuntu18.04.4 LTS 64 bit.

Below you can see two screenshots. In the first one I introduced a radius of 3,4 cm (with comma) and you can see that the area as well as the conductance for H2 is the expected one:

If I instead give the radius with a dot, the decimal is ignored:

The code I use to parse the number is as simple as it can get:

bool GLTextField::GetNumber(double *num) {

  int conv = sscanf(m_Text,"%lf",num);
  return (conv==1);

}

However - and I always learn something new - it looks like sscanf supports locales:

https://stackoverflow.com/questions/13919817/sscanf-and-locales-how-does-one-really-parse-things-like-3-14

It seems that on your Ubuntu setup comma is chosen as decimal separator. Can you check?

https://www.thomas-krenn.com/en/wiki/Configure_Locales_in_Ubuntu

Ups, I didn't know anything about locale...

Yes, indeed I had LC_NUMERIC=de_DE.utf-8 in my locale by default. If I change it to en_US.utf-8 then Molflow+ effectively takes the point as the correct decimal separator.

However, typing a comma does not raise the error you showed in your first answer, but ignores the decimals instead. Could it be that I have to configure further settings in my computer?

Thanks for spending your time with this issue :-)

Thanks for debugging!

And you're right, currently I check if one number could have been interpreted, but indeed, I should also check if the full string was used (as opposed to only the part before a comma, for example).

I'll keep experimenting how it's done on different platforms and push a fix in one of the future versions.

Many thanks for reporting the issue!