RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.StrToBoolDef Function

Converts a string to a Boolean value, with error default.

Pascal
function StrToBoolDef(const S: string; const Default: Boolean): Boolean;
C++
Boolean StrToBoolDef(const AnsiString S, const Boolean Default);

SysUtils

StrToBoolDef converts the string specified by S to a Boolean. If S can be converted to a number, StrToBoolDef returns false if that number is 0, true otherwise. If S can't be converted to a number, StrToBoolDef returns true if S is any of the strings listed in TrueBoolStrs (or differs from one only by case) and false if it is any of the strings listed in FalseBoolStrs (or differs from one only by case). If S is not a number and not one of the strings listed in TrueBoolStrs or FalseBoolStrs, StrToBoolDef returns Default.

Note: If you do not assign a value to TrueBoolStrs, it is treated as if it contains the single string 'True'. Similarly, if you do not assign a value to FalseBoolStrs, it is treated as if it contains the single string 'False';
Note: The TrueBoolStrs and FalseBoolStrs variables are undefined when an application starts. Any use of StrToBool, BoolToStr or TryStrToBool will cause these variables to be initialised with the default values above.
 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!