Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
VCL
8-Byte Alignment
Action Classes
Additional Controls
Core VCL Classes
Streaming
TApplication
TApplicationEvents
TCollection
TControl
TForm
TFrame
TList
TScreen
TThread
TWinControl
TypeInfo
DFM to TEXT
Dialog Controls
Docking
Drag/Drop
Emulation Classes
Exceptions
Gestures
Graphics
MAPI Support
MDI Support
Multi-Monitor Support
OnGesture event
Printing
Property/Type Editors
Registry / INI Objects
Ribbon Controls
Sample Controls
Services
Standard Controls
Styles
System Controls
Thread support
Touch Controls
Type Info
Win 3.1 Controls
Win 32 Controls
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/VCL/Core VCL Classes
[ Add a report in this area ]
Report #:
42481
Status:
Reported
TCustomIniFile.WriteFloat/ReadFloat are Language Setting dependant
Project:
Delphi
Build #:
10.0.2288.42451
Version:
10.0
Submitted By:
Horst Reichert
Report Type:
Basic functionality failure
Date Reported:
3/13/2007 7:29:19 AM
Severity:
Commonly encountered problem
Last Updated:
Platform:
All platforms
Internal Tracking #:
Resolution:
None
Resolved in Build:
:
None
Duplicate of:
None
Voting and Rating
Overall Rating:
(2 Total Ratings)
5.00 out of 5
Total Votes:
None
Description
As the above class methods use the language setting dependant methods FloatToStr(Value) to write and FloatStr() to read values, the result will depend on the Windows language setting of the Decimal separator.
A language independent result could be obtained replacing the DecimalSeparator (Which might be , ) with the dot writing the value, and using the Val method reading the data.
Steps to Reproduce:
None
Workarounds
None
Attachment
None
Comments
Giel Bremmers at 3/26/2007 3:35:09 PM
-
Overriding ReadFloat with this function has solved this problem for me:
function TMyIniFile.ReadFloat(const Section, Name: string; Default: Double): Double;
var Str: String;
i: integer;
begin
Str := inherited ReadString(Section, Name, FloatToStr(Default));
i := pos(',', str);
if i > 0 then str[i] := '.'; //nederlandse windows zet komma's in inifiles!
try
Result := StrToFloat(Str);
except
on EConvertError do Result := Default; //waarom geeft dit toch error met komma's?
else raise;
end;
end;
Horst Reichert at 3/26/2007 11:29:11 PM
-
I know how to work around this trap.
I do this in a similar way.
The problem is that the Ini component is claiming to store and load floating point/datetime etc values, but is only storing language dependant string representations.
Especially american and english software authors will run into this trap because they normally do not care about.
Borland/Codegear should not provide any language dependant components at all. They should either make a clear warning to the documentation or depreciate those components.
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us