From Clomosy Docs
function Random():Extended;
The random function generates random numbers. These can be floating-point numbers in the following range:
0 <= Number < 1.0
It can be used by calling as follows. This call will generate a decimal random number value between 0 and 1.
x := Random();
If you want to get an integer value, define it as follows. Here it will return a random value between 0 and 100. After that, you can get values as you want.
x := Random() * 100;
Example:
var MyForm:TclForm; btnShow : TclButton;
procedure randomNumber var number:Float; begin number := Random() * 100; ShowMessage(IntToStr(number)); end;
begin MyForm := TclForm.Create(Self);
btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Random'); btnShow.TextSettings.Font.Size:=50; btnShow.Align := alCenter; btnShow.Height := 50; btnShow.Width := 100; MyForm.AddNewEvent(btnShow,tbeOnClick,'randomNumber');
MyForm.Run; end;