944,123 Members | Top Members by Rank

Ad:
Apr 20th, 2007
0

arrays and randomize

Expand Post »
hey there, umm so i have an array of words and now i need to be able to randomly choose one of those words when the appropriate button is clicked, its for a hangman game...
i know that
randomize;
goes in there sumwhere...

thanks heaps..
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
sez90 is offline Offline
9 posts
since Apr 2007
Apr 21st, 2007
0

Re: arrays and randomize

and what you can not accomplish?
Reputation Points: 14
Solved Threads: 16
Junior Poster
radu84 is offline Offline
171 posts
since Dec 2006
Apr 23rd, 2007
0

Re: arrays and randomize

selectedword := words[random(high(MAX_WORDS))];

Assuming words array is 0 based like :

words : array [0..MAX_WORDS] of string;
Reputation Points: 28
Solved Threads: 4
Posting Whiz in Training
Lord Soth is offline Offline
233 posts
since Mar 2006
Jul 2nd, 2007
0

Re: arrays and randomize

Before calling random function you should call procedure randomize, it will initiate pseudorandom number generator.
It's necessary because without calling procedure randomize you will get the same random sequence
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Emelinn is offline Offline
1 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Pascal assistance
Next Thread in Pascal and Delphi Forum Timeline: DBGrid - how to autosize cells





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC