<% dim strResult 'this will hold our html string for display strResult = "" strResult = strResult & "<form action='latin.asp' method='GET'>" strResult = strResult & "<input type='text' size='2' name='paras' />" strResult = strResult & "&nbsp;&nbsp;&nbsp;" strResult = strResult & "<input type='submit' value='Generate' />" strResult = strResult & "</form>" dim cntParas cntParas = Request.Querystring( "paras" ) If cntParas <> "" then 'we have output to display, so let's show it strResult = strResult & "<hr />" strResult = strResult & GetLatinParas( cntParas ) End If 'display the output response.write( strResult ) '====================================================================================================================== Function GetLatinParas( cntParas_IN ) 'accepts a positive integer and returns a string containing a series of paragraphs (delimited by <p></p>) 'function randomly determines the number of words in each sentence and the placement of commas 'localize inputs dim cntParas cntParas = cntParas_IN dim i 'external loop counter dim x 'internal loop counter dim cntSentence 'number of sentences in a particular paragraph - random dim cntWords 'number of words in a particular sentence - random dim strResult 'the result we will return to the caller For i = 1 to cntParas 'randomly determine the number of sentences in this paragraph 'we'll set this to minimum of 3 sentences and maximum of 7 'this should make all our old english teachers proud :D Randomize cntSentence = Int( ( 7 - 3 + 1 ) * Rnd + 3 ) 'start building the paragraph strResult = strResult & "<p>" For x = 1 to cntSentence 'randomly determine the number of words in this sentence 'for our purposes we'll say no less than 8, no more than 25 Randomize cntWords = Int( ( 25 - 8 + 1 ) * Rnd + 8 ) strResult = strResult & GetLatinSentence( cntWords ) Next strResult = strResult & "</p>" Next 'return the string to the caller GetLatinParas = strResult End Function Function GetLatinSentence( cntWords_IN ) 'accepts a positive integer and returns a string of text containing the requested number of words. 'localize inputs dim cntWords cntWords = cntWords_IN 'set up the string and the array of words dim strLatin 'the base string we build the array from dim arrLatin 'array of the words we will use strLatin = LCase( "lorem ipsum dolor sit amet consectetuer adipiscing elit sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat ut wisi enim ad minim veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi Ut wisi enim ad minim veniam quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi" ) arrLatin = Split( strLatin, " " ) 'this will be our output dim strResult strResult = "" 'start building the output 'build a random number between 0 and the upper limit of the string dim iRandom 'our random number Randomize iRandom = Int( UBound( arrLatin ) * Rnd ) 'first we start the sentence with a capital letter strResult = strResult & PCase( arrLatin( iRandom ) ) dim blnComma 'flag to see if we place a comma For i = 1 to cntWords 'build a random number between 0 and the upper limit of the string Randomize iRandom = Int( UBound( arrLatin ) * Rnd ) 'check to see if we are going to include a comma after this word 'to prevent having a comma after every two or three words, we'll set it to only a 1 in 10 chance Randomize blnComma = Int( 8 * Rnd ) If blnComma = 1 then 'yes we include a comma strResult = strResult & "," End If strResult = strResult & " " strResult = strResult & arrLatin( iRandom ) Next 'finally, we add a period and a space at the end of the sentence strResult = strResult & ". " 'return the result GetLatinSentence = strResult End Function Function PCase(strInput) 'taken from http://line9.com/tek9.asp?pg=freebies&specific=9 iPosition = 1 Do While InStr(iPosition, strInput, " ", 1) <> 0 iSpace = InStr(iPosition, strInput, " ", 1) strOutput = strOutput & UCase(Mid(strInput, iPosition, 1)) strOutput = strOutput & LCase(Mid(strInput, iPosition + 1, iSpace - iPosition)) iPosition = iSpace + 1 Loop strOutput = strOutput & UCase(Mid(strInput, iPosition, 1)) strOutput = strOutput & LCase(Mid(strInput, iPosition + 1)) PCase = strOutput End Function %>