Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Random Function Problem

Status
Not open for further replies.

wrightson

Technical User
Jan 27, 2002
2
0
0
GB
Ive got a quiz that works by clicking a button it assigns a random number between 1 and 15. These relate to markers that pick out a question. The problem is when a random number is picked it sometimes turns up twice ie the same question is asked again! Not what i need! Is it possible to get the random function to assign a list of five random numbers and then call them? If so how?
This is the code that i have at present:
This is placed on the next question button:
on mouseup me
put random(15) into X
if x=1 then
go to "1"
addpoint
else if x=2 then
go to "2" etc etc etc etc

This is in my movie script:
global qnumber
on addqpoint
if number >4 then
go to "finish"
else
qnumber = qnumber 1
end if
end

PLEASE HELP!
 
What you can do is when any random number is generated, check in a global list to see if it has already been generated. So when the first random no is generated, the list will be empty. So you add it to the list. Starting from the next number, traverse the list and check if it has already been generated. If not go ahead and display your question, if not generate a new one.

Mayuresh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top