When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
Published: Sunday, May 28, 2000

Generating Random "Fake Latin" Strings, Part 2

By Dave Cantrell

  • Read Part 1

  • In Part 1 we looked at the GetLatinSentence function, which generated fake Latin sentences. In this part we'll look at the function GetLatinParas, which generates fake Latin paragraphs!

    - continued -

    This function simplifies using the GetLatinSentence() function. As with GetLatinSentence(), we declare the function and localize the inputs:

    Function GetLatinParas( cntParas_IN )
      dim cntParas
      cntParas = cntParas_IN

    We also have a series of variables we should go ahead and set up now:

      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

    Now we start the loop. In here we (1) randomly determine the number of sentences in this paragraph, (2) build each sentence using GetLatinSentence, and (3) concatenate the result onto strResult. I set the paragraph length here to a minimum of three and maximum of seven sentences.

      For i = 1 to cntParas
        cntSentence = Int( ( 7 - 3 + 1 ) * Rnd + 3 )
        'start building the paragraph
        strResult = strResult & "

    " 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 & "

    " Next

    Finally, return the string to the caller and close:

      GetLatinParas = strResult
    End Function

    There is a live demo available which allows the user to select a variable number of fake Latin paragraphs to be generated. If you're curious as to the output, go ahead and give the demo a run!

    Anyways, hopefully these functions will help you out next time you need demo text in a hurry. It sure would have helped me! :D



  • Download the source code for latin.asp in text format
  • Try out the live demo!

  • ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article