
-----------------------------------
fabulos
Sat Jan 22, 2005 2:15 pm

Random Words
-----------------------------------
how do i pick random words from a list of words?  like 

Helo
Bye
Good Day
Good Bye 


thx

-----------------------------------
xHoly-Divinity
Sat Jan 22, 2005 2:24 pm


-----------------------------------
Firstly you must use randint. It would end up looking something like this...


var x : int
randint (x, 1, 4)
if x = 1 then
    put "hello"
elsif x = 2 then
    put "Bye"
elsif x = 3 then
    put "Good day"
elsif x = 4 then
    put "Good bye"
end if


-----------------------------------
Neo
Sat Jan 22, 2005 2:28 pm


-----------------------------------
Store your words in an array and call them using Rand.Int.


var word : array 1 .. 4 of string := init ("Hello", "Bye", "GoodBye", "GoodDay")
put word (Rand.Int (1, 4))


-----------------------------------
basketball4ever
Sat Jan 22, 2005 3:03 pm


-----------------------------------
If you dont like using arrays : P like myself cos i'm strange...
you can always use case

works just like an if statement... but IMO better... 
store all of em as 
word1
word2
word3
word4
then rand em

-----------------------------------
SuperGenius
Sat Jan 22, 2005 4:07 pm


-----------------------------------
If you dont like using arrays : P like myself cos i'm strange...
you can always use case

works just like an if statement... but IMO better... 
store all of em as 
word1
word2
word3
word4
then rand em

don't listen. This is terrible form.

-----------------------------------
MysticVegeta
Sat Jan 22, 2005 8:36 pm


-----------------------------------
I agree, if you can do a random word using 2 lines of code and between unlimited words then why use a case?

-----------------------------------
person
Sun Jan 23, 2005 11:28 am


-----------------------------------
i agree with "SuperGenius" and "Mystic Vegeta", arrays are so much better than unlimited number of codes :D

-----------------------------------
MysticVegeta
Wed Jan 26, 2005 7:02 pm

Re: Random Words
-----------------------------------
how do i pick random words from a list of words?  like 

Helo
Bye
Good Day
Good Bye 


thx

Here is the code :
var words : array 1 .. 4 of string := init ("hello", "Hi", "Bye", "GoodBye")
put words (Rand.Int (1, 4))

not so hard with arrays now is it, all you gotta do is make the array to 1..(whatever number u wish) and insert the same amount of strings separated by spaces in the array. Then, edit the Rand.Int formula to 1, (the number of strings you chose)

-----------------------------------
fabulos
Fri Jan 28, 2005 7:25 pm


-----------------------------------
wow...thanks so much!!!...

this'll help me a lot for my french exam..lol

thx again

-----------------------------------
DarkBlazer
Sat Jan 29, 2005 9:12 am


-----------------------------------
lol.... w/e just wanted to say case isnt good example for this problem (been there done that)

-----------------------------------
mike200015
Sun Jan 30, 2005 1:35 pm


-----------------------------------
how would you use that type of thing, but say you wanted to use 50 words?
would you have to still use :=init (.....) and set what all the words are?

-----------------------------------
basketball4ever
Sun Jan 30, 2005 1:39 pm


-----------------------------------
how would you use that type of thing, but say you wanted to use 50 words?
would you have to still use :=init (.....) and set what all the words are?


unless you're importing a text file... yes you would have to do that.
