Substring.ToBoolean Method

Overload List

#SignatureDescription
1function ToBoolean: Boolean; overload;Converts the text to a Boolean.
2class function ToBoolean(const S: Substr.Substring): Boolean; overload; static;
3class function ToBoolean(const S: string): Boolean; overload; static;

Overload 1: function ToBoolean: Boolean; overload;

Converts the text to a Boolean.

Returns: Boolean - For a number (a text ToDouble accepts), True unless it is 0; else True or False for a name in TrueBoolStrs or FalseBoolStrs ('True' and 'False' when unset), A to Z and a to z matching each other, every other character only itself.

Remarks:

Any other text raises EConvertError: '<text>' is not a valid boolean value. The class forms take every text kind.

Examples

Names and numbers.

uses Substr;

procedure Example;
begin
    Assert(Substring('true').ToBoolean);
    Assert(not Substring.ToBoolean('0'));
end;
See Also: Substr.StrToBool

Overload 2: class function ToBoolean(const S: Substr.Substring): Boolean; overload; static;

#NameTypeDescription
1SSubstr.Substring

Returns: Boolean

Overload 3: class function ToBoolean(const S: string): Boolean; overload; static;

#NameTypeDescription
1Sstring

Returns: Boolean