At startup the plugin code does a check to try and convert a '123.456' string to a float. If it works then it's going to use '.' as the separator. If it fails then it assumes it needs to be ','.
Code: Select all
// see what localisation works
decimalSymbol:='.';
try
f:=StrToFloat('123.456');
except
decimalSymbol:=',';
end;
log.text(2,'Decimal Symbol',decimalSymbol);
When reading from the DB a field such as LASTTIMEPLAYED is read as a string. Any occurrences of the wrong separator is converted to the right one. This makes the plugin tolerant to reading either type of separator.
Code: Select all
function replaceDecimalSymbol(s:WideString):WideString;
begin
if decimalSymbol='.' then
Result:=StringReplace(s,',','.',[])
else
Result:=StringReplace(s,'.',',',[]);
end;
Now, when the plugin writes to the DB the float is converted to a string by using MM's Localize function.
Code: Select all
function MMdateToFloatStr(d:Tdatetime):WideString;
var
s:string;
diff:Tdatetime;
begin
diff:=d-datetime0;
s:=QuotedStr(MMInterf.Localize(floatToStr(double(diff))));
Result:=s;
end;
And I think that is where the fault lies. The reading is handled by my bespoke code whereas the writing is handled by the Localize function. The Localize function will use the display language and I'm using the locale.
In all cases that I know my users have the same display language as their locale (or the separators for the two are the same anyway). You have a mix of Italian and English which have difference separators.
As a test can you set your display language to Italian and see in the correct separator is written into the database?
At startup the plugin code does a check to try and convert a '123.456' string to a float. If it works then it's going to use '.' as the separator. If it fails then it assumes it needs to be ','.
[code] // see what localisation works
decimalSymbol:='.';
try
f:=StrToFloat('123.456');
except
decimalSymbol:=',';
end;
log.text(2,'Decimal Symbol',decimalSymbol);
[/code]
When reading from the DB a field such as LASTTIMEPLAYED is read as a string. Any occurrences of the wrong separator is converted to the right one. This makes the plugin tolerant to reading either type of separator.
[code]function replaceDecimalSymbol(s:WideString):WideString;
begin
if decimalSymbol='.' then
Result:=StringReplace(s,',','.',[])
else
Result:=StringReplace(s,'.',',',[]);
end;
[/code]
Now, when the plugin writes to the DB the float is converted to a string by using MM's Localize function.
[code]function MMdateToFloatStr(d:Tdatetime):WideString;
var
s:string;
diff:Tdatetime;
begin
diff:=d-datetime0;
s:=QuotedStr(MMInterf.Localize(floatToStr(double(diff))));
Result:=s;
end;
[/code]
And I think that is where the fault lies. The reading is handled by my bespoke code whereas the writing is handled by the Localize function. The Localize function will use the display language and I'm using the locale.
In all cases that I know my users have the same display language as their locale (or the separators for the two are the same anyway). You have a mix of Italian and English which have difference separators.
As a test can you set your display language to Italian and see in the correct separator is written into the database?