Click to See Complete Forum and Search --> : Question on Randomizer segment


fcoffman
08-15-2003, 12:57 PM
I've been modifying Don Cross's Random Sentence/Story Generator and would like to know (since I'm pretty good at modifying, but not much good at all at creating javascript) how the following sequence could be changed to allow for numbers of 10, 11 or greater NOT BEING READ as 1 and 0, 1 and 1, etc.:

unction GenRandomSentence() {
var stemp = GenRandomSentenceTemplate()
var i
var s = ""
for ( i=0; i<stemp.length; i++ ) {
var c = stemp.substring(i,i+1)
var w = ""
if ( c == '0' ) w = GenNoun()
else if ( c == '1' ) w = GenNounPhrase(0)
else if ( c == '2' ) w = GenTransitiveVerbPhrase(1)
else if ( c == '3' ) w = GenConjunction()
else if ( c == '4' ) w = GenIntransitiveVerbPhrase()
else if ( c == '5' ) w = GenTransitiveVerbPhrase(0)
else if ( c == '6' ) w = GenAdjective()
else if ( c == '7' ) w = GenAdverb()
else if ( c == '8' ) w = GenProperName()
else if ( c == '9' ) w = GenAttributiveVerb()
else w = c
s += w
}

In other words, how would I go beyond 9 to other lists of various other tagged parts of speech or phrase varieties?

Any advice would be greatly appreciated.

Khalid Ali
08-15-2003, 01:53 PM
If I understood it correctly,just amore conditions

c=='10') and the appropriate method here

that should work..