Author |
Message |
fabulos
|
Posted: Sat Jan 22, 2005 2:15 pm Post subject: Random Words |
|
|
how do i pick random words from a list of words? like
Helo
Bye
Good Day
Good Bye
thx |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
xHoly-Divinity
|
Posted: Sat Jan 22, 2005 2:24 pm Post subject: (No subject) |
|
|
Firstly you must use randint. It would end up looking something like this...
code: |
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
|
|
|
|
|
|
![](images/spacer.gif) |
Neo
![](http://compsci.ca/v3/uploads/user_avatars/441131374462fea7633fd3.gif)
|
Posted: Sat Jan 22, 2005 2:28 pm Post subject: (No subject) |
|
|
Store your words in an array and call them using Rand.Int.
code: |
var word : array 1 .. 4 of string := init ("Hello", "Bye", "GoodBye", "GoodDay")
put word (Rand.Int (1, 4))
|
|
|
|
|
|
![](images/spacer.gif) |
basketball4ever
|
Posted: Sat Jan 22, 2005 3:03 pm Post subject: (No subject) |
|
|
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 |
|
|
|
|
![](images/spacer.gif) |
SuperGenius
|
Posted: Sat Jan 22, 2005 4:07 pm Post subject: (No subject) |
|
|
basketball4ever wrote: 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. |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Sat Jan 22, 2005 8:36 pm Post subject: (No subject) |
|
|
I agree, if you can do a random word using 2 lines of code and between unlimited words then why use a case? |
|
|
|
|
![](images/spacer.gif) |
person
|
Posted: Sun Jan 23, 2005 11:28 am Post subject: (No subject) |
|
|
i agree with "SuperGenius" and "Mystic Vegeta", arrays are so much better than unlimited number of codes ![Very Happy Very Happy](http://compsci.ca/v3/images/smiles/icon_biggrin.gif) |
|
|
|
|
![](images/spacer.gif) |
MysticVegeta
![](http://www.geocities.com/ohsoinsane/my_avatar.JPG)
|
Posted: Wed Jan 26, 2005 7:02 pm Post subject: Re: Random Words |
|
|
fabulos wrote: how do i pick random words from a list of words? like
Helo
Bye
Good Day
Good Bye
thx
Here is the code :
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) |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
fabulos
|
Posted: Fri Jan 28, 2005 7:25 pm Post subject: (No subject) |
|
|
wow...thanks so much!!!...
this'll help me a lot for my french exam..lol
thx again |
|
|
|
|
![](images/spacer.gif) |
DarkBlazer
|
Posted: Sat Jan 29, 2005 9:12 am Post subject: (No subject) |
|
|
lol.... w/e just wanted to say case isnt good example for this problem (been there done that) |
|
|
|
|
![](images/spacer.gif) |
mike200015
|
Posted: Sun Jan 30, 2005 1:35 pm Post subject: (No subject) |
|
|
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? |
|
|
|
|
![](images/spacer.gif) |
basketball4ever
|
Posted: Sun Jan 30, 2005 1:39 pm Post subject: (No subject) |
|
|
mike200015 wrote: 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. |
|
|
|
|
![](images/spacer.gif) |
|