How do I generate a random number in Jade6

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

How do I generate a random number in Jade6

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:55 am

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?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: How do I generate a random number in Jade6

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:55 am

by cnwrwm1 >> Thu, 15 Apr 2004 0:34:30 GMT

One way is to use the app.random method (of Application class).

Cheers ....Richard

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: How do I generate a random number in Jade6

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:55 am

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.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: How do I generate a random number in Jade6

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:55 am

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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: How do I generate a random number in Jade6

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:55 am

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.


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 7 guests