Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Selecting random words

Author
Message
Col
21
Years of Service
User Offline
Joined: 4th Jan 2003
Location:
Posted: 7th Jan 2003 03:46
Could anyone help me with this, I have the feeling the answer is obvious, but I can't for the life of me find a way round it:

I want to select one word randomly from a group of words in much the same way one selects a random number. Is there a quick way of doing this, for instance by listing all the words together.
So far I have only been able to assign each word an individual value, and then check each value with an IF THEN statement. There must be a more efficient way.

Any help greatly appreciated
Xsniper
21
Years of Service
User Offline
Joined: 29th Dec 2002
Location:
Posted: 7th Jan 2003 04:33
I would recommend making a string array that holds all your words and then do a if - then statement on a random value which will be able to select your word. The reason for this is by making an array each word is assigned a value anyway from 0 to whatever the max array size is. So do your random value and check if your array(value) is equal to that value, etc. Hope I explained that well enough.

Hamish McHaggis
21
Years of Service
User Offline
Joined: 13th Dec 2002
Location: Modgnik Detinu
Posted: 8th Jan 2003 00:02
Just expanding on what xsniper said, use something like



Yum! Yum! Yum! Yum!
Col
21
Years of Service
User Offline
Joined: 4th Jan 2003
Location:
Posted: 12th Jan 2003 23:12
Great. Think I'm getting my head round this.
It's really great of you guys to be giving up your time to help newcomers to programming BTW
Cheers

Login to post a reply

Server time is: 2024-05-17 03:23:57
Your offset time is: 2024-05-17 03:23:57