×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# question

## question

(OP)
I have one question, first of akll I want to thanks to everyone who gives me advice for director.
Qustion is:
I hava database of 40 questions with a,b,c,d answer. How can I make randomize questions of 10 questions.
Thank you.

### RE: question

#### CODE

on generate10randomNumFrom40
list40 = []
repeat with i = 1 to 40
list40.append(i)
end repeat
n = 40
repeat while n > 1
m = random(n)
tN = list40[n]
tM = list40[m]
list40[n] = tM
list40[m] = tN
n = n - 1
end repeat
list10 = []
repeat with i = 1 to 10
list10[i] = list40[i]
end repeat
return list10
end generate10randomNumFrom40

put generate10randomNumFrom40()
-- [29, 9, 32, 2, 1, 5, 23, 31, 21, 35]

put generate10randomNumFrom40()
-- [24, 28, 40, 21, 35, 20, 30, 11, 33, 18]

Kenneth Kawamoto
www.materiaprima.co.uk

### RE: question

(OP)
Sorry because I am boring but I am beginner, can you tell me where I need to put this code and how to integrate this code with my data base of question .

### RE: question

The code above is to obtain 10 random numbers from 1 - 40. I don't know how you structure your database, but say you have 40 questions in a List; you can use the 10 random numbers as index to pick up 10 random questions.

Kenneth Kawamoto
www.materiaprima.co.uk

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!