Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / RND command....

Author
Message
Pastry Like Dood
19
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 16th Jul 2005 12:53
Would this be how i set up a RND?

RND (1,100)? And also, how would i print the number into a PRINT thingy? Would it be something like:

Print "Blah blah blah blah"
RND (1,100);a#
PRINT "You got";a#;"blah blah blah"

Also how would i get it set up so once the RND amount REACHES a combined total of 200 it PRINTs something?
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 16th Jul 2005 16:32 Edited at: 16th Jul 2005 16:34
first of all to make your random numbers truely random you need to feed the randomize command a seed or random number, the easiest way to do this is to go

randomize timer()

it takes the timer() number which is a number counting from midnight on this current day

randomize 234234 is what it would say at one specific time of the day as an example

a mini example of what you would want is similar to this code.



im not on a pc at the momo so there may be a few mini bugs.

If no-one gives your an answer to a question you have asked, consider:- Is your question clear.- Did you ask nicely.- Are you showing any effort to solve the problem yourself 
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 16th Jul 2005 19:30
This is useful. You can make a bunch of little functions like this when you program to save you time and headaches.

function Rand(min,max)
diff=max-min
base=rnd(diff-1)
result=base+min+1
endfunction result


I forget if rnd() starts at zero or 1. Here I assumed it would start from 0. If it starts at one remove the "-1" from "base=rnd" and the "+1" from "result=base+min".

Crazy Donut Productions
Current Project: A Redneck game
Pastry Like Dood
19
Years of Service
User Offline
Joined: 16th Jul 2005
Location:
Posted: 17th Jul 2005 07:04
This helps alot, thanks guys!

Login to post a reply

Server time is: 2024-09-23 23:26:35
Your offset time is: 2024-09-23 23:26:35