BoolToStr
BoolToStr converts a boolean value into a string, using the following grid.
Depending on whether you specify UseBoolStrs to be True or False, will determine the string result that is returned - either True or False, or a string consisting of the numeric values minus one (-1), or zero (0).
Result of Input String B | Value of UseBoolStrs | Value of Returned String |
|---|---|---|
True | False | Minus one ‘-1’. |
True | False | Zero '0'. |
False | True | ‘True’. |
False | True | ‘False’. |
Please also refer to BooltoFloString for detail about this similar function.
Declaration: Function BoolToStr(B: boolean; UseBoolStrs: boolean): string;
Several examples to illustrate the returned values are detailed below.
procedure ScriptEvent(var Value:Variant);var TheText, FullText, Which, Which2 : string; BoYN : boolean;begin FullText := 'Jack and Jill went up the hill to fetch a pail of water.'; TheText := 'Jack and Jill'; BoYN := StartsStr(TheText, FullText); //Using 'true' as the UseBoolStrs value means that either 'True' or 'False' will be returned Which := BoolToStr(BoYN, true); Loginfo('This is TRUE. This should return TRUE . . . '+Which); //Using 'false' as the UseBoolStrs value means that either '-1' or '0' will be returned Which := BoolToStr(BoYN, false); Loginfo('This is TRUE. This should return -1 . . . '+Which); LogInfo(''); TheText := 'John and Betty'; BoYN := StartsStr(TheText, FullText); //Using 'true' as the UseBoolStrs value means that either 'True' or 'False' will be returned Which2 := BoolToStr(BoYN, true); LogInfo('This is FALSE. This should return FALSE . . . '+Which2); //Using 'false' as the UseBoolStrs value means that either '-1' or '0' will be returned Which2 := BoolToStr(BoYN, false); LogInfo('This is FALSE. This should return 0 . . . '+Which2);end;