From Clomosy Docs

Revision as of 10:48, 28 February 2023 by ClomosyManager (talk | contribs) (Created page with " function Random():Extended; The random function generates random numbers. These can be floating-point numbers in the following range:<br> 0 <= Number < 1.0 <br> It can be used by calling as follows. This call will generate a decimal random number value between 0 and 1.<br> 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.<br> x := Random(...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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:TFrmClomosyBasisForm;
 btnShow : TclButton;
procedure randomNumber var number:Float; begin number := Random() * 100; ShowMessage(IntToStr(number)); end;
begin MyForm := TFrmClomosyBasisForm.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;