StrToBoolDef

From SCAR Divi Manual
Jump to: navigation, search

Definition

function StrToBoolDef(s: AnsiString; def: Boolean): Boolean;

Availability

SCAR Divi 3.00 > Current

Description

Converts a given string Str to a boolean value. If Str equals 'false' or '0', the result will be [false], if the Str is 'true' or a string representing any integer value that does not equal 0, the function returns true. In the event that Str is not a valid boolean value, the function will return the given value def.

Example

begin
  WriteLn(StrToBoolDef('True', False));
  WriteLn(StrToBoolDef('False', False));
  WriteLn(StrToBoolDef('lol', False));
end.

Output:

1
0
0

See Also