Generating Random "Fake Latin" Strings

During a recent meeting I presented some initial design comps for a planned enterprise-wide web site re-design.
The focus at this point was on information architecture, and the designs were in the initial draft stage, only
to be used to give the higher management an idea of the scope and impact of these changes. It wasn't long
before the designs were criticized by several people, not for their design, but for the content -- I had cut & pasted
actual content from the existing web sites with the intent to help provide a better mental image. However, they
took it upon themselves (after being told otherwise, no less) to point out the factual and grammatical errors
in the text. Rankled, I decided not to encounter this problem anymore.

I remembered Jakob Nielsen's Alertbox article on using
"greeked" text to test designs, and decided to put it to good use. I had been on the lookout for an app
that would generate this text for me but had no luck. Then I found some sample munged-up text and proceeded to
write a few functions to handle this for me. Bear in mind this is ASP code, but should be easily portable to a
VB app or client-side DHTML.

The two functions are GetLatinSentence and GetLatinParas. GetLatinSentence
accepts an integer and returns a fully-formed sentence containing the specified number of random words, with
the first word capitalized and commas randomly spaced throughout. GetLatinParas accepts an integer
and returns the specified number of paragraphs, each containing a random number of sentences generated from
GetLatinSentence. A new random number is passed in each time GetLatinSentence is called.

On to the code...

GetLatinSentence()
This is the larger of the two functions. First, we declare the function as normal and then localize the input
variables (always a good practice! eliminates changing the input value and losing track of it!):

Now we start building the output. First we do Randomize to insure we get a random seed value. I
used the UBound value of the array in the iRandom calculation because we use
iRandom to reference the array's ordinal positions.

Next we start the sentence by pulling one word out of the array at random and and converting the first letter
to uppercase. I used the most excellent PCase function from line9.com for this
(link is in the source code).

strResult = strResult & PCase( arrLatin( iRandom ) )

blnComma is a flag the script will set randomly and use to see if we should insert a comma after
each word.

dim blnComma 'flag to see if we place a comma

Now we start the loop. We reset the iRandom variable because we don't want the same word to come
out twice in a row. It still might with the way the script is currently written, but at least it's less
probable.

For i = 1 to cntWords
'build a random number between 0 and the upper limit of the string
Randomize
iRandom = Int( UBound( arrLatin ) * Rnd )

Next is a check to see if we should put a comma after this word. Since we don't want a comma every second or
third word, we set this to a one-in-ten chance. (BTW, since we add the comma to strResult before
adding the next word, we shouldn't get any commas followed by periods)