1. Home
  2. Computing & Technology
  3. Delphi Programming
GlossaryTips/Tricks|FREE App/VCL|Essentials|Books|Link Back

Delphi Programming RTL Reference|By Category|Alphabetically|By Unit
 

BoolToStr

unit
SysUtils
category
type conversion routines

declaration
function BoolToStr(B: Boolean; UseBoolStrs: Boolean = False): string;

description
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.

example
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'

in real code

see also
IntToStr, SetLength, StrToBool


 Free Delphi code snippet inside every Delphi Newsletter!
Subscribe to the Newsletter
Name
Email

 Got some code to share? Got a question? Need some help?
Explore Delphi Programming
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. Delphi Programming

©2009 About.com, a part of The New York Times Company.

All rights reserved.