RBoolEx

From SCAR Divi Manual
Revision as of 13:33, 4 July 2011 by Freddy (talk | contribs) (Created page with "==Definition== <source lang="scar" lines="false"> function RBoolEx(Chance: Integer): Boolean; </source> ===Source Code=== <source lang="scar"> function RBoolEx(Chance: Integer):...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Definition

function RBoolEx(Chance: Integer): Boolean;

Source Code

function RBoolEx(Chance: Integer): Boolean;
begin
  if Chance = 0 then
    Result := True
  else
    Result := Random(Chance) = 0;
end;

Availability

SCAR Divi 3.00 > Current

Description

Returns a random boolean value with a change of 1/Chance that the returned value is true. If Chance is 0, true is returned.

Example

var
  i: Integer;
begin
  for i := 1 to 5 do
    WriteLn(RBoolEx(10));
end.

See Also