(Delphi ActiveX) Generating Random Integer in Range
Demonstrates how to generate random integers in a specified range.
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;
...
procedure TForm1.Button1Click(Sender: TObject);
var
chilkatGlob: TChilkatGlobal;
success: Integer;
fortuna: TChilkatPrng;
i: Integer;
begin
// All Chilkat classes can be unlocked at once at the beginning of a program
// by calling UnlockBundle. It requires a Bundle unlock code.
chilkatGlob := TChilkatGlobal.Create(Self);
success := chilkatGlob.UnlockBundle('Anything for 30-day trial.');
if (success <> 1) then
begin
Memo1.Lines.Add(chilkatGlob.LastErrorText);
Exit;
end;
fortuna := TChilkatPrng.Create(Self);
// Generate random integers between 12 and 24 inclusive
for i := 0 to 100 do
begin
Memo1.Lines.Add(IntToStr(fortuna.RandomInt(12,24)));
end;
end;
|