Im trying to create a plugin for Webuilder which needs to process floating point values, but it turns out to be a real pain.
Example:
Code: Select all
var teststring = _t( 7/3 );
var testfloat = StrToFloat(teststring);
Script.Message(unitMatch);
Script.Message(_t(fl));
Notice the decimal separator used is a COMMA, not a PERIOD.
While on Windows 7, I get the value: 2.33333333333333
Notice the decimal separator used is a PERIOD.
So how to use floating point values in a plugin?
Currently I do something like this:
Code: Select all
// Create a floating point number and remove the digits to get the decimal seperator.
var decimalSeparator = RegexReplace(_t(5/2), "\\d*", "", true);
Code: Select all
StrToFloat(Replace(floatString, ".", decimalSeparator));
According to the Delphi docs, you can add a 2nd parameter to StrToFloat().
But this parameter (TFormatSettings) is an object, and AFIK it's not possible to create objects in Webuilder plugins.
Program used: WeBuilder 2015 v13.2.0.164