From Clomosy Docs
(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(...") |
No edit summary |
||
| Line 13: | Line 13: | ||
'''Example:'''<br> | '''Example:'''<br> | ||
'''var''' | '''var''' | ||
MyForm: | MyForm:TclForm; | ||
btnShow : TclButton;<br> | btnShow : TclButton;<br> | ||
'''procedure randomNumber''' | '''procedure randomNumber''' | ||
| Line 22: | Line 22: | ||
end;<br> | end;<br> | ||
'''begin''' | '''begin''' | ||
MyForm := | MyForm := TclForm.Create(Self);<br> | ||
btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Random'); | btnShow:= MyForm.AddNewButton(MyForm,'btnShow','Random'); | ||
btnShow.TextSettings.Font.Size:=50; | btnShow.TextSettings.Font.Size:=50; | ||
Revision as of 14:24, 3 April 2023
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;