Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;
Returns a string from a boolean value.
When UseBoolStrs is True then if b equals True, the function returns the first string in TrueBoolStrs; if b equals False, the function returns the first string in FalseBoolStrs. Where FalseBoolStrs and TrueBoolStrs are global Delphi variables (dynamic string arrays) you can set and use when converting a boolean variable to string and back.
var b : boolean;
b:=True;
{ first example }
//BoolToStr(b) = '-1' (* true *)
//BoolToStr(NOT b) = '0' (* false *)
{ second example }
SetLength(TrueBoolStrs,1);
SetLength(FalseBoolStrs,1);
TrueBoolStrs[0]:='YES';
FalseBoolStrs[0]:='NO';
ShowMessage(BoolToStr(True, True));
//this will result in 'YES'
ShowMessage(BoolToStr(False, True));
//this will result in 'NO'
|
IntToStr, SetLength, StrToBool
|
Free Delphi code snippet inside every Delphi Newsletter! |
|
|
|
Got some code to share? Got a question? Need some help? |
|
|