Page 1 of 1
How do I generate a random number in Jade6
Posted: Fri Aug 07, 2009 10:55 am
by ConvertFromOldNGs
by Jade starter >> Wed, 14 Apr 2004 23:59:15 GMT
I need to generate random number in Jade6. Do I use some functions to do it or have other ways?
Re: How do I generate a random number in Jade6
Posted: Fri Aug 07, 2009 10:55 am
by ConvertFromOldNGs
by cnwrwm1 >> Thu, 15 Apr 2004 0:34:30 GMT
One way is to use the app.random method (of Application class).
Cheers ....Richard
Re: How do I generate a random number in Jade6
Posted: Fri Aug 07, 2009 10:55 am
by ConvertFromOldNGs
by Anonymous >> Sat, 10 Jul 2004 4:39:22 GMT
vars
i : Integer;
begin
i := app.random(50);
write i;
end;
attach to a button on a form (button_click) then each time you click the button, a random number between 1 and 50 will be written to the interpreter window.
Re: How do I generate a random number in Jade6
Posted: Fri Aug 07, 2009 10:55 am
by ConvertFromOldNGs
by
carlranson >> Sun, 11 Jul 2004 1:02:14 GMT
I think you'll find its a number between 0 and 50.
Last i heard this was "working as intended" and NOT an off by one bug.
CR
Re: How do I generate a random number in Jade6
Posted: Fri Aug 07, 2009 10:55 am
by ConvertFromOldNGs
by Jade Support >> Mon, 12 Jul 2004 2:21:32 GMT
Correct, app.random(50) will generate a random number in the range 0-50 inclusive. As a note there is a new method available in JADE 6.0, app::random31().
random31(seed : Integer io; range: Integer): Integer;
The Application class random31 method returns a random positive number in the range 0 through the value of the range parameter, inclusive. Use this method to generate random numbers with a larger range of values compared to the Application class random method.
In addition, the random31 method enables you to generate multiple sets of random numbers within a single application, by maintaining multiple values of the seed parameter.
Aaron.