Delphi DLL
Delphi DLL
Generating Random Integer in Range
See more PRNG Examples
Demonstrates how to generate random integers in a specified range.Chilkat Delphi DLL Downloads
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Prng;
...
procedure TForm1.Button1Click(Sender: TObject);
var
success: Boolean;
fortuna: HCkPrng;
i: Integer;
begin
success := False;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
success := False;
fortuna := CkPrng_Create();
// Generate random integers between 12 and 24 inclusive
for i := 0 to 100 do
begin
Memo1.Lines.Add(IntToStr(CkPrng_RandomInt(fortuna,12,24)));
end;
CkPrng_Dispose(fortuna);
end;