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.

DarkBASIC Discussion / randomized printing

Author
Message
the chode
20
Years of Service
User Offline
Joined: 27th Apr 2005
Location: desert
Posted: 5th May 2005 13:40
as one of our (friend and i) first programs, we are making a random insult generator. basically, you type in your name, and the computer will pick from a list which ones to say. we have gotten it to the point where you input your name, but we need to know how to randomly draw an insult. i think it has something to do with the insults being strings???

Dude
NanoBrain
20
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 5th May 2005 14:20 Edited at: 5th May 2005 14:21
the chode,

Create a string array and fill the slots with your jokes.



For the random selector, simply use the rnd function to select a random number in between 0 and array length.



Below is a runnable code snippet. Try it out.




+NanoBrain+
the chode
20
Years of Service
User Offline
Joined: 27th Apr 2005
Location: desert
Posted: 5th May 2005 14:24
thanx!

Dude

Login to post a reply

Server time is: 2025-05-23 02:20:32
Your offset time is: 2025-05-23 02:20:32