[fpc-pascal] BoolToStr

Zeljko Avramovic avra at writeme.com
Wed Aug 31 15:10:45 CEST 2022


> > You can use
>
> BoolToStr(b,'TRUE','FALSE')
>
> That works great!  Shouldn't that be the default and you can put in
> something else if you want it?

Latest trunk allows you this if you include new syshelpers unit:

True.ToString;                                          // True
True.ToTrueFalseString(scfUpperCase);                   // TRUE
True.ToString('OnState', 'OffState');                   // OnState
True.ToString('Running', 'Stopped', scfUpperCase);      // RUNNING

It also allows you to populate TBitFormatSettings with your strings for TRUE and FALSE and gives you method CopyToDefaultBoolStrings. This changes boolean to string text outputs in syshelpers and some other places. Maybe that could fit your bill.

More info can be found in this demo:
https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/rtl-objpas/examples/syshelpersdemo.pas


More information about the fpc-pascal mailing list