Computer Science Canada

Rand Int

Author:  cam [ Sun Jan 21, 2007 2:18 pm ]
Post subject:  Rand Int

Why doesn't this work?


Rand.Int (1, 6)
if Rand.Int (1) then
put "haha"
end if

Author:  lord_pwnerer [ Sun Jan 21, 2007 3:00 pm ]
Post subject:  Re: Rand Int

code:
var number : int

randint(number,1,6)

if number = 1 then
put"haha the number = 1"
end if


Use randint instead of Rand.Int... When you use randint you can assign a variable to the number, then check what that variable was set to.

EDIT: By the way, the reason that it doesn't work is when you wrote Rand.Int the second time, it was just like calling the procedure a second time, not checking to see what the random number was. (sorry if this doesn't make any sense, I'm in a rush)

Author:  Robert [ Sun Jan 21, 2007 3:05 pm ]
Post subject:  RE:Rand Int

Rand.Int is a function...

code:

if Rand.Int(1,6) = 1 then
     put "haha"
end if


Always use Rand.Int instead of randint

Author:  cam [ Sun Jan 21, 2007 3:37 pm ]
Post subject:  Re: Rand Int

o thx very much

Author:  Cervantes [ Sun Jan 21, 2007 7:37 pm ]
Post subject:  Re: Rand Int

lord_pwnerer @ Sun Jan 21, 2007 3:00 pm wrote:

Use randint instead of Rand.Int... When you use randint you can assign a variable to the number, then check what that variable was set to.


Please, don't say this. It's fantastically wrong. It's so wrong, we've even got a mini tutorial to explain it. Read it, and learn!


: