Answer:
Here is the code snippet to do the job.
If the second parameter is omitted, the function returns "TRUE" or "FALSE".
Modify the function declaration to change the default returning values.
Expand TBooleanWordType and BooleanWord definitions to include more specific values if needed.
interface
[...]
type
TBooleanWordType =
(bwTrue, bwYes, bwOn, bwEnabled, bwSuccessful, bwOK, bwOne);
[...]
function BoolToStr (AValue: boolean;
ABooleanWordType: TBooleanWordType = bwTrue): string;
[...]
{=====================================================}
implementation
[...]
const
BooleanWord: array [boolean, TBooleanWordType] of string =
(
('FALSE', 'No', 'Off', 'Disabled', 'Failed', 'Cancel', '0'),
('TRUE', 'Yes', 'On', 'Enabled', 'Successful', 'OK', '1')
);
[...]
{-----------------------------------------------------}
function BoolToStr (AValue: boolean;
ABooleanWordType: TBooleanWordType = bwTrue): string;
begin
Result := BooleanWord [AValue, ABooleanWordType];
end; {--BoolToStr--}
[...]
|