StrToBool

From SCAR Divi Manual
Revision as of 17:02, 5 July 2011 by Freddy (talk | contribs) (Undo revision 861 by Freddy (talk))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

function StrToBool(Str: AnsiString): 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 throw an exception.

Example

begin
  WriteLn(StrToBool('True'));
  WriteLn(StrToBool('False'));
  WriteLn(StrToBool('true'));
  WriteLn(StrToBool('false'));
  WriteLn(StrToBool('1'));
  WriteLn(StrToBool('0'));
  WriteLn(StrToBool('2'));
  WriteLn(StrToBool('5'));
end.

Output:

1
0
1
0
1
0
1
1

See Also