
-----------------------------------
[Gandalf]
Sun Mar 13, 2005 3:51 pm

Difference between Rand.Int and randint?
-----------------------------------
What is the difference, if there is one?  I have looked around these forums, and took a look at the desciptions in Turing Help, but the descriptions are exactly the same...  This has been at the back of my mind since I got Turing 4.05 (before I was using DOS Turing  :) ), and I feel its time I should know.

It's the same for Rand.Next/randnext and randseed/Rand.Seed and other things like that too.  :?

-----------------------------------
Tony
Sun Mar 13, 2005 4:05 pm


-----------------------------------
one's a function, another is a procedure that takes a pointer to a variable as an argument.

-----------------------------------
[Gandalf]
Sun Mar 13, 2005 4:20 pm


-----------------------------------
Alright, I see - is there any difference on how they generate random numbers?  I can use both of them in my situation, but is there any advantage to using one over the other?  Thanks!

-----------------------------------
illu45
Sun Mar 13, 2005 5:39 pm


-----------------------------------
Using the Documentation, Rand.Int (low, high : int) : int seems to be the same as randint ( var i : int, low, high : int ) except for the fact that for fandint you have to assign a variable (var i), whereas in Rand.Int you don't.

-----------------------------------
Tony
Sun Mar 13, 2005 6:36 pm


-----------------------------------
since Rand.Int() is a function, it could be used in chains

-----------------------------------
person
Sun Mar 13, 2005 7:59 pm


-----------------------------------
all this stuff is like 

Draw.Oval=drawoval
Draw.Box=drawbox

and etc.

-----------------------------------
Cervantes
Sun Mar 13, 2005 8:23 pm


-----------------------------------
No.  Draw.Box is a procedure.  drawbox is a procedure.  They are the same.  THAT is like colourback and colorback.  However, Rand.Int is a function, whereas randint is a procedure.  They are different.
Rand.Int is better, because as tony says, it can be used in chains.  ie.

Draw.FillOval (Rand.Int (100, 200), Rand.Int (200, 300), Rand.Int (3, 10), Rand.Int (5, 12), Rand.Int (1, 16))

vs.

var x, y, xradius, yradius, clr : int
randint (x, 100, 200)
randint (y, 200, 300)
randint (xradius, 3, 10)
randint (yradius, 5, 12)
randint (clr, 1, 16)
Draw.FillOval (x, y, xradius, yradius, clr)

1 line vs. 7 lines.  And the randint approach also means declaring lots of extra, messy, unnecessary variables.

-----------------------------------
ssr
Sun Mar 13, 2005 9:37 pm


-----------------------------------
tnx for the tutorial and tnx for clearing that out 
Cervantes
 :lol: 
I was confused with it
it could've save me a lot of time, and lines
:p
