Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 getting one integer from Rand.Int
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
jay_vee




PostPosted: Mon Jun 04, 2007 5:09 pm   Post subject: getting one integer from Rand.Int

I need to use Rand.Int to choose a random number from 1 to 10. What I have is ship1X1 := Rand.Int (1, 10) ->ship1X1 is my variable. Rand.Int gives me never ending values from 1 to 10 for ship1X1, how do I make it so that it only saves one number? I tried

loop
ship1X1 := Rand.Int (1, 10)
exit when ship1X1 = 1 or ship1X1 = 2 or ship1X1 = 3 or ship1X1 = 4 or ship1X1 = 5 or ship1X1 = 6 or ship1X1 = 7 or ship1X1 = 8 or ship1X1 = 9 or ship1X1 = 10
end loop


which apparently was a waste of time, because it still ouputs more than one number.

Help please? Smile
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Jun 04, 2007 5:11 pm   Post subject: RE:getting one integer from Rand.Int

what do you mean? having:

Turing:
ship1X1 := Rand.Int (1, 10)


is all you need, ship1X1 will get a single value from 1 to 10.
Geostigma




PostPosted: Mon Jun 04, 2007 5:12 pm   Post subject: RE:getting one integer from Rand.Int

Turing:

if event then
Rand.Int (ship1X1,1, 10)
end if
jay_vee




PostPosted: Mon Jun 04, 2007 6:19 pm   Post subject: Re: getting one integer from Rand.Int

okay, sorry. The mistake I made was I put the Rand.Int in a procedure which I put in a loop -_-". So it kept giving me different numbers. But I fixed it Smile
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: