[fpc-devel] TIniFile with option ifoWriteStringBoolean

Michael Van Canneyt michael at freepascal.org
Wed Mar 16 13:42:57 CET 2022

On Wed, 16 Mar 2022, Bart via fpc-devel wrote:

> Hi,
> User Nimral in the wiki noted this:
> If you specify ifoWriteStringBoolean in Options for TIniFile _and_ you
> forget to assign values to BoolTrueStrings/BoolFalseStrings, then
> writing and reading boolean values is not symmetrical.
> Writing a boolean will write either 'true' or 'false', but reading
> calls CharToBool on the found string.
> Consider this piece of code:
>  Ini := TIniFile.Create('test.ini');
>  Ini.Options := [ifoWriteStringBoolean]; //[ifoWriteStringBoolean]

It does not say ifoReadStringBoolean or ifoReadWriteStringBoolean for a
reason. So the behaviour is as designed.

The behaviour was introduced for compatibility with other development

Which is not to say that we cannot change the behaviour.



More information about the fpc-devel mailing list