Page 1 of 1

Woah this is really important!

Posted: Thu Jan 20, 2005 8:39 pm
by Athy
If you have a program that randomly selects say 5 words from a list of 20 or w/e how do you errortrap it or w/e so that the same word is not picked twice?

Thanks so much!

<3

Ps. This is my friends thing and this is her code for it I can't really explain it but here it is if it helps.

var num : int
var Tim3 : int := 1
var words : array 1 .. 20 of string (15) := init ("1)Amazing", "2)Banana", "3)Cherries", "4)Dance", "5)Elephant", "6)Fantastic", "7)Game", "8)Ice", "9)Kangaroo", "10)Love", "11)Marshmallow","12)Octopus", "13)Pig", "14)Rainbow", "15)Strawberries", "16)Turtle", "17)Umbrella","18)Violin","19)Xylophone","20)Wiggle")
for x : 1 .. 10
Tim3 := Tim3 + 1
randint (num, 1, 20)

put words (num)
delay (1000)
exit when Tim3 = 11
end for

Archived topic from Iceteks, old topic ID:3038, old post ID:24964

Woah this is really important!

Posted: Thu Jan 20, 2005 10:11 pm
by Red Squirrel
I would just use an if statement to ensure value A is not equal to B C D or E then make sure B is not equal to A C D or E etc.... there's probably a better way of doing it though.

Archived topic from Iceteks, old topic ID:3038, old post ID:24965

Woah this is really important!

Posted: Thu Jan 20, 2005 10:42 pm
by Athy
Thank anyways!

Archived topic from Iceteks, old topic ID:3038, old post ID:24966